How to retrieve security id from the registry?

  • Thread starter Thread starter jenny
  • Start date Start date
J

jenny

Hi,

Is anyone has any idea on how to retrieve the security id
that is being created based on random number for each new
user, ie. S-1-5-21-xxx...

I would like to get the entire string of S-1-5-21-xxx...

Any windows scripting sample for the above available?

Appreciate your response and advise. Thank you,.

- jenny
 
jenny said:
Is anyone has any idea on how to retrieve the security id
that is being created based on random number for each new
user, ie. S-1-5-21-xxx...

I would like to get the entire string of S-1-5-21-xxx...

Any windows scripting sample for the above available?

Appreciate your response and advise. Thank you,.

Hi

You can use vbscript/WMI to get the SID of the current user like this:


WScript.Echo "User SID: " & GetUserSID


Function GetUserSID()

Dim sUserSID, oWshNetwork, oUserAccount

Set oWshNetwork = CreateObject("WScript.Network")
sUserSID = ""

On Error Resume Next
Set oUserAccount=GetObject( _
"winmgmts://" & oWshNetwork.UserDomain & "/root/cimv2") _
.Get("Win32_UserAccount.Domain='" & oWshNetwork.ComputerName & "'" _
& ",Name='" & oWshNetwork.UserName & "'")

GetUserSID = oUserAccount.SID

End Function
 
jenny said:
Is anyone has any idea on how to retrieve the security id
that is being created based on random number for each new
user, ie. S-1-5-21-xxx...

I would like to get the entire string of S-1-5-21-xxx...

Any windows scripting sample for the above available?

Appreciate your response and advise. Thank you,.

Hi

You can use vbscript/WMI to get the SID of the current user like this:


WScript.Echo "User SID: " & GetUserSID


Function GetUserSID()

Dim sUserSID, oWshNetwork, oUserAccount

Set oWshNetwork = CreateObject("WScript.Network")
sUserSID = ""

On Error Resume Next
Set oUserAccount=GetObject( _
"winmgmts://" & oWshNetwork.UserDomain & "/root/cimv2") _
.Get("Win32_UserAccount.Domain='" & oWshNetwork.ComputerName & "'" _
& ",Name='" & oWshNetwork.UserName & "'")

GetUserSID = oUserAccount.SID

End Function
 
In said:
Hi,

Is anyone has any idea on how to retrieve the security id
that is being created based on random number for each new
user, ie. S-1-5-21-xxx...

I would like to get the entire string of S-1-5-21-xxx...

Any windows scripting sample for the above available?

Appreciate your response and advise. Thank you,.

Perhaps:
----------
PsGetSid v1.1 - local and remote account/machine SID displayer
Copyright (C) 2000 Mark Russinovich
http://www.sysinternals.com

PsGetSid displays the machine SID for the local or remote NT system.

Usage: psgetsid [\\RemoteComputer [-u Username [-p Password]]] [account]
-u Specifies optional user name for login to
remote computer.
-p Specifies optional password for user name. If you omit this
you will be prompted to enter a hidden password.
account PsGetSid will report the SID for the specified user account
rather than the computer.
 
In said:
Hi,

Is anyone has any idea on how to retrieve the security id
that is being created based on random number for each new
user, ie. S-1-5-21-xxx...

I would like to get the entire string of S-1-5-21-xxx...

Any windows scripting sample for the above available?

Appreciate your response and advise. Thank you,.

Perhaps:
----------
PsGetSid v1.1 - local and remote account/machine SID displayer
Copyright (C) 2000 Mark Russinovich
http://www.sysinternals.com

PsGetSid displays the machine SID for the local or remote NT system.

Usage: psgetsid [\\RemoteComputer [-u Username [-p Password]]] [account]
-u Specifies optional user name for login to
remote computer.
-p Specifies optional password for user name. If you omit this
you will be prompted to enter a hidden password.
account PsGetSid will report the SID for the specified user account
rather than the computer.
 
Back
Top