Partager via


Working with Live Communications Server User Instances

 
Microsoft Office Live Communications Server 2005 with SP1

Working with Live 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 Live Communications Server in the domain, WMI must contact that particular server. Therefore, Live 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 Live Communications Server Domain User Admin group.

Creating a Live Communications Server User Instance

This function connects to a remote machine and creates a new Live 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 a Live Communications Server User Instance

This function connects to the WMI service and updates a Live 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 a Live Communications Server User Instance

This function connects to the WMI service and deletes the specified Live 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?
  © 2008 Microsoft Corporation. All rights reserved.