Working with Office Communications Server User Instances
Communications Server 2007 Server SDK Documentation |
Working with Office Communications Server User Instances
The following code samples illustrate connecting to the Windows Management Instrumentation (WMI) service and creating, updating, and deleting user instances. It is important to note that if the user is homed on another Office Communications Server in the domain, WMI must contact that particular server. Therefore, Office Communications Server must be running and available on the user's home server.
To execute this code successfully, you must be a member of the Office Communications Server Domain User Admin group.
Creating an Office Communications Server User Instance
This function connects to a remote computer and creates a new Office Communications Server User instance on it.
[VBScript] Public Function CreateInstance(InstanceId, Enabled, PrimaryURI, UserDn, HomeServerDN) Set DefaultSIPUserInstance = GetObject("WinMgmts:MSFT_SIPESUserSetting") 'Do error checking here. Set NewSIPUserInstance = DefaultSIPUserInstance.SpawnInstance_ NewSIPUserInstance.InstanceID = InstanceID NewSIPUserInstance.UserDN = UserDN NewSIPUserInstance.HomeServerDN = HomeServerDN NewSIPUserInstance.PrimaryURI = PrimaryURI NewSIPUserInstance.Enabled = Enabled Err.Clear() NewSIPUserInstance.Put_ 0 'Do error checking here. CreateInstance = true End Function
Updating an Office Communications Server User Instance
This function connects to the WMI service and updates an Office Communications Server User instance with the specified values.
[VBScript] Public Function UpdateInstance(InstanceId, Enabled, PrimaryURI, UserDN, HomeServerDN) ' Connect to the WMI server. Set wmiServer = CreateObject("WbemScripting.SWbemLocator").ConnectServer() Query = "SELECT * FROM MSFT_SIPESUserSetting where InstanceID = '" & InstanceID & "'" Set LCUserEnum = wmiServer.ExecQuery(Query) For each LCUser in LCUserEnum '//update values here LCUser.InstanceID = InstanceID LCUser.UserDN = UserDN LCUser.HomeServerDN = HomeServerDN LCUser.PrimaryURI = PrimaryURI LCUser.Enabled = Enabled LCUser.Put_ 0 '0 for create or update 'Do error checking here. Next UpdateInstance = True End Function
Deleting an Office Communications Server User Instance
This function connects to the WMI service and deletes the specified Office Communications Server User instance based on the supplied primary URI of the user.
Public Function DeleteInstance(UserURI) ' Connect to WMI server Set wmiServer = CreateObject("WbemScripting.SWbemLocator").ConnectServer() 'Do error checking here Query = "SELECT * FROM MSFT_SIPESUserSetting where PrimaryURI = '" & UserURI & "'" Set LCUserEnum = wmiServer.ExecQuery(Query) For each LCUser in LCUserEnum Err.Clear LCUser.Delete_ 'Do error checking here Next DeleteInstance = true End Function
What did you think of this topic? |
© 2007 Microsoft Corporation. All rights reserved. |