我正在编写一个我想与 Active Directory 以及本地用户和组一起使用的应用程序。我想我可以使用 DirectoryEntry 的 NativeGuid 属性作为唯一标识符,该标识符是使用 WinNT 提供程序针对 LocalHost 检索的。但是,在LinqPad中使用以下代码,我得到了两个条目相同的 NativeGuid。使用 LDAP 提供程序查询活动目录似乎会产生独特的结果,但现在我不确定。
System.DirectoryServices.DirectoryEntry localuserde =
new System.DirectoryServices.DirectoryEntry("WinNT://localhost/localuser");
localuserde.NativeGuid.Dump("localUser Guid");
System.DirectoryServices.DirectoryEntry adminde =
new System.DirectoryServices.DirectoryEntry("WinNT://localhost/administrator");
adminde.NativeGuid.Dump("administrator Guid");
有人可以解释一下在使用 WinNT 提供程序时 NativeGuid 代表什么吗?uniqueId 是否有更好的替代品,或者 SID 是更好的选择吗?
要在 LinqPad 中运行上述内容,请按 F4 并将 System.DirectoryServices.dll 添加到程序集列表中。然后确保 localuser 存在或将名称更改为系统上的本地用户。然后按F5。
谢谢,
肖恩持有人