Friday, June 18, 2010

Get user SID and vice versa

For a Citrix problem, support team had to know correspondance between user or computer name and SID. If you don't know what is SID, it's something like S-1-5-21-1009609029-4169793705-2371228398 and correspond to an unique identifier of a user, computer or group (see definition in Technet Glossary at http://technet.microsoft.com/en-us/library/cc776189(WS.10).aspx#s)

Well In my toolbox I have 2 very old vbs scripts from Shane Boudreaux that permit to convert SID to username and vice versa

Convert Username to SID
http://www.thescriptlibrary.com/Default.asp?Action=Display&Level=Category3&ScriptLanguage=VBScript&Category1=Security&Category2=Other&Title=Convert%20Username%20to%20SID (Alternate Download)

Convert SID to Username
http://www.thescriptlibrary.com/Default.asp?Action=Display&Level=Category3&ScriptLanguage=VBScript&Category1=Security&Category2=Other&Title=Convert%20SID%20to%20Username (Alternate Download)

But now Microsoft sysinternals have a tool PsGetSid (http://technet.microsoft.com/en-us/sysinternals/bb897417.aspx) (Alternate Download) that do the same

If you need to know how sysinternals do, you can check source code sid2user.cpp and user2sid.cpp from Evgenii B. Rudnyi http://evgenii.rudnyi.ru/soft/sid/ (Alternate Download user2sid.cpp and sid2user.cpp)

If you are a powershell geek, go directly to Powershell Guy blog http://thepowershellguy.com/blogs/posh/archive/2007/01/23/powershell-converting-accountname-to-sid-and-vice-versa.aspx (Alternate Download)

No comments: