Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Get User SID (for login scripts)

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,45540
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Get User SID (for login scripts)
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Get User SID (for login scripts) - 4/6/2007 2:02:49 AM   
  ginolard


Posts: 1021
Score: 21
Joined: 8/10/2005
Status: offline
I ran into a thorny problem today.  How to get the user's SID during logon?  I couldn't query the owner of the explorer.exe process because it hadn't started yet.  I didn't want to use any external tools like PsGetSID.  I also didn't want to query AD as I didn't want to take the risk that the user didn't have access to that.  So, I came up with this little "hack".

It creates an environement variable of the user's Fullname.  It then walks through HKEY_USERS trying to find in which key the associated registry key for that environment variable has been created.  Once it finds that, it knows what the SID is because it'll be the name of the parent key. 


      


_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm
 
 
Post #: 1
 
 RE: Get User SID (for login scripts) - 4/6/2007 3:21:56 AM   
  DiGiTAL.SkReAM


Posts: 1140
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: online
Under the key "HKEY_CURRENT_USER\Software\Microsoft\Protected Storage System Provider" there is a subkey that matches the HKEY_USER\subkey key for the current user.


      


< Message edited by DiGiTAL.SkReAM -- 4/6/2007 3:30:10 AM >


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to ginolard)
 
 
Revisions: 2 | Post #: 2
 
 RE: Get User SID (for login scripts) - 4/6/2007 4:27:10 AM   
  ginolard


Posts: 1021
Score: 21
Joined: 8/10/2005
Status: offline
*grumble*

Typical

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 3
 
 RE: Get User SID (for login scripts) - 4/6/2007 4:38:06 AM   
  DiGiTAL.SkReAM


Posts: 1140
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: online
Sorry man, I just ran into this same problem myself 2 weeks ago, so had the solution on-hand.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to ginolard)
 
 
Post #: 4
 
 RE: Get User SID (for login scripts) - 4/6/2007 7:42:24 AM   
  dm_4ever


Posts: 2366
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
Another possible way...


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ginolard)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Get User SID (for login scripts) Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts