GetUserNameFromSessionID Method

Gets the UserName from a specified SessionID on a Terminal Server.


  obj.GetUserNameFromSessionID(SessionID long, UserName string, [ComputerName string])
  where obj is an OpScrUtil.TermServer object 


SessionID Specifies the ID of the Session.
UserName Specifies the name of the user associated with the SessionID.
ComputerName Specifies the target computer. This parameter is optional. If not specified or an empty string, the local computer is the target.

Return Type



To get the UserName associated with the given SessionID, enter:

	 Set obj = CreateObject("OpScrUtil.TermServer")
	 bOK = obj.GetUserNameFromSessionID(SessionID, sUsername)
	 if bOK then MsgBox "The UserName is " & sUserName

This example shows how to get the name of a user connected to a Terminal Server Session.