Working with Office Communications Server User Instances
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
These code samples illustrate how to connect to the Windows Management Instrumentation (WMI) service and how to create, update, and delete user instances.
All of these code samples require Office Communications Server to be running and available on the user's home server. If the user is homed on another Office Communications Server in the domain, WMI must still contact that particular server.
To execute these code samples, you must be a member of the Office Communications Server Domain User Admin group.
This function connects to a remote computer and creates a new Office Communications Server User instance on it.
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
This function connects to the WMI service and updates an Office Communications Server User instance with the specified values.
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
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