我将用户的 SID 设为 byte[]
在 windowsPrincipal.getIdentity().getSid()
内.
如何从 SID 获取 Active Directory 条目 (DirectoryEntry)?
最佳答案
我发现最简单的方法是使用 LDAP 绑定(bind)。类似于尼克吉尔斯所说的。更多信息请访问 MSDN
''' <summary>
''' Gets the DirectoryEntry identified by this SecurityIdentifier.
''' </summary>
''' <param name="id">The SecurityIdentifier (SID).</param>
<System.Runtime.CompilerServices.Extension()> _
Public Function GetDirectoryEntry(ByVal id As SecurityIdentifier) As DirectoryEntry
Const sidBindingFormat As String = "LDAP://AOT/<SID={0}>"
Return New DirectoryEntry(String.Format(sidBindingFormat, id.Value))
End Function
关于directoryentry - 给定用户的 SID,我如何获取 AD DirectoryEntry?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7090179/