【问题标题】:System.DirectoryServices - how to NOT query Active Directory for properties having the confidential bit setSystem.DirectoryServices - 如何不向 Active Directory 查询设置了机密位的属性
【发布时间】:2011-08-08 22:08:36
【问题描述】:

我正在使用 DirectoryServices 来查询个人或组的 DirectoryEntries,如下所示:

var propsToLoad = new string {"sAMAccountName","objectClass", "memberOf", "distinguishedName", "manager","mail","name","objectCategory"};
DirectoryEntry dEntry = new DirectoryEntry("LDAP://<MyDomainController>/DC=foo,FC=com","user","pass");
DirectorySearcher dSearch = new DirectorySearcher(dEntry, "(&(|(objectClass=person)(objectClass=group))
(samAccountName=jsmith))", propsToLoad);
var searchResult = s.FindOne();
var searchResultDirEntry = result.GetDirectoryEntry();

我遇到的问题是上述为SearchResult 获取DirectoryEntry 的调用获取的属性比我查询的要多。 如果我在调试时将鼠标悬停在 searchResult 上,它只包含我查询的 8 个属性,但在 searchResult 查询中调用 "GetDirectoryEntry()" 更多 属性(大约 77 - 80 多个属性值)。

真正的问题是它还在查询设置了“机密位”的属性,例如 'UnixUserPassword' 导致对 DC 的审计失败。

有没有办法指定不查询任何设置了机密位的属性或具有result.GetDirectoryEntry(); 尊重 我的“propsToLoad”,并且只获取我在 DirectorySearcher 上指定的属性的属性值。

【问题讨论】:

    标签: .net active-directory directoryservices


    【解决方案1】:

    不,不是真的。您的 propsToLoad 数组被传递到 LDAP 搜索。当您调用 GetDirectoryEntry() API 时,它是一个完全不同的代码路径。如果您想要这种级别的控制,您将需要使用 S.DS.Protocols 直接对抗 LDAP。

    【讨论】:

    • 在“System.DirectortyServices”命名空间中有没有这样做的例子?
    • 正如我所说,ADSI 不允许您根据其架构反射的工作方式来控制它。
    • 我最终只是在 SearchResult 中查询 PropertyValues,而不是继续使用 S.DS
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多