如何知道 Windows 用户账户的 SID?

如何知道 Windows 用户账户的 SID?

当您查看HKEY_USERS注册表项时,每个子项(代表每个用户的设置)看起来类似于 S-1-5-18,SID我猜是这么叫的。

我如何知道哪个SID是适用于哪个用户帐户的?

答案1

如何将用户名与安全标识符 (SID) 关联

Open Registry Editor and navigate to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion \ProfileList

Under the ProfileList key, you will see the SIDs. By selecting each one individually, you can look at the value entry and see what user name is associated with that particular SID.

答案2

可以使用获取Sid还。

答案3

我使用以下 VB 脚本,而不是安装其他实用程序。我不能为其中的各个组件负责,只能为它们的组合负责:

查找_SID

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

UserName = UserInput( "Enter the user name:", "" )
Domain = UserInput( "Enter the domain / PC name:", "")

Set objAccount = objWMIService.Get _
("Win32_UserAccount.Name='" & UserName & "',Domain='" & Domain & "'")
Call UserInput( "The SID for " & Domain & "\" & UserName & " is: ", objAccount.SID )

Function UserInput( myPrompt, default_text )
' This function prompts the user for some input.
' When the script runs in CSCRIPT.EXE, StdIn is used,
' otherwise the VBScript InputBox( ) function is used.
' myPrompt is the the text used to prompt the user for input.
' The function returns the input typed either on StdIn or in InputBox( ).
' Written by Rob van der Woude
' http://www.robvanderwoude.com
    ' Check if the script runs in CSCRIPT.EXE
    If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
        ' If so, use StdIn and StdOut
        WScript.StdOut.Write myPrompt & " "
        UserInput = WScript.StdIn.ReadLine
    Else
        ' If not, use InputBox( )
        UserInput = InputBox( myPrompt,, default_text )
    End If
End Function

答案4

我在互联网上其他地方找到的 Powershell(没有原始来源):

$objSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxx-xxxxxx") 
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) 
$objUser.Value

此外,这个链接可能也有一定价值: SID 的详细信息

相关内容