問:我想通過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