Saturday, September 14, 2013

Get SID of a User Account

To get the SID(Security Identifier) of a particular User ID we may use multiple methods. Some of them are mentioned below:

1. Using Registry Editor (only for logged in users)
  • Method 1: Goto Run(press Window+R or Start->Run), type regedit and press ok. It will open the Registry Editor then goto the following path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and expand it. Then you have to select the folders prefixed with S-1-5-21. As you select them on the right pane of the window you will find a String type "ProfileImagePath" which will display the username.
  • Method 2: In regedit, goto the HKEY_USERS folder and the first key with prefix S-1-5-21 is currently logged in user's SID.
(NOTE: Modifying registry may cause any system-wide troubles or may even crash it)

2. Open Command Prompt, goto Run type "cmd" and press OK. Now in the command prompt type "wmic useraccount get name,sid" and it will display the list of usernames and their SID's.

3. Using scripting, open notepad and paste the below script in it:
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set objAccount = objWMIService.Get("Win32_UserAccount.Name='administrator',Domain='Abhishek'")
Wscript.Echo objAccount.SID

Change the UserAccount.Name and Domain as per your requirement and then save the file as script.vbs(make filetype as "All types") and then run the file. It will display your SID

4. Using external tools such as PsGetSid: http://technet.microsoft.com/en-us/sysinternals/bb897417.aspx

If anybody knows any other way for this then please do comment :)

No comments:

Post a Comment