How to retrieve security id from the registry?

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
 
T

Torgeir Bakken (MVP)

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
 
T

Torgeir Bakken (MVP)

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
 
M

Mark V

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.
 
M

Mark V

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top