Page 1 of 1 1
Topic Options
#202785 - 2011-08-02 10:14 PM Client ID using GetSessionID()
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
Hello,

We have a bunch of thin clients and are upgrading our terminal servers from 2003 to 2008 R2. 2008 R2 now creates a subkey named the TS Session ID for the session number and puts the "ClientName" in it. With that being said, I hacked at this a bit and it is working. Thought I would share and ask for some constructive criticism, as I am very much a hack at this. Thanks All.

GetSessionID() is a sweet little UDF by pearly

 Code:
$session = GetSessionID() 
? $session

$UserSID = "HKEY_USERS\" + @SID 

$ClientName = @WKSTA
	
If InStr(@PRODUCTTYPE,"Server") and InStr(@PRODUCTTYPE,"2008")
	$ClientName = ReadValue($UserSID + "\Volatile Environment\" + $Session,"CLIENTNAME")
ENDIF

If InStr(@PRODUCTTYPE,"Server") and InStr(@PRODUCTTYPE,"2003")
	$ClientName = ReadValue($UserSID + "\Volatile Environment","CLIENTNAME")
ENDIF


Edited by Skip (2011-08-03 05:22 PM)
_________________________
-sphilip

Top
#202786 - 2011-08-02 10:48 PM Re: Client ID using GetSessionID() [Re: Skip]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Nothing wrong with your code. I like working with functions better so maybe something like this...

untested, requires getsessionid()

? clientname()
 Code:
function Clientname()
  select
    case InStr(@PRODUCTTYPE,"Server 2008")
      $ClientName = ReadValue("HKEY_USERS\" + @SID  + "\Volatile Environment\" + getsessionid(),"CLIENTNAME")
    case InStr(@PRODUCTTYPE,"Server 2003")
      $ClientName = ReadValue("HKEY_USERS\" + @SID  + "\Volatile Environment","CLIENTNAME")
    case 1  
      $ClientName = @WKSTA
  endselect
endfunction

Top
#202791 - 2011-08-03 05:18 PM Re: Client ID using GetSessionID() [Re: Allen]
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
That function works perfect. Thanks for taking the time to clean it up and reply. Most appreciated.
_________________________
-sphilip

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.053 seconds in which 0.022 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org