问:我想通过SID获得本地Windows用户:通过SID获取本地用户
我发现这个代码
[ADSI]("WinNT://$Env:Computername/<SID=S-1-5-18>")
我从中推导,我可以在(VB).NET中做到这一点:
Dim strURL As String = "WinNT://" + strComputerName + "/<SID=" + strSID + ">"
Dim de As DirectoryServices.DirectoryEntry = New DirectoryServices.DirectoryEntry(strURL)
de.Properties("whatever").Value.ToString()
但是,这不起作用。 任何人都知道我怎么能做到这一点没有循环所有用户(这需要先从字节[]转换为字符串,然后比较[不区分大小写]很多字符串,这使得它很慢)。
不,的DirectoryServices,不会的PInvoke。此外,如果我愿意,我可以在托管代码中获得NTaccount。 – 2011-02-28 11:54:55