0

我正在使用该Novell.Directory.Ldap.NETStandard从 Active Directory 中读出用户和组。到目前为止一切正常。现在我需要从 AD 中获取所有已删除的对象,这目前还不起作用。

我能够在我的服务器上使用 ldp.exe 查看已删除的用户,但无法CN=Deleted Objects,DC=myDC从 Novell 库访问 DN。

以下是我尝试获取已删除用户的方法:

  IEnumerable <string> GetDeletedUsers(ILdapConnection conn)
        {
            string searchFilter = "(objectclass=person)";
            List<string> objectList = new List<string>();

            LdapSearchResults searchResults = PrepareSearch(conn, "CN=Deleted Objects,DC=myDC", searchFilter);
            while (searchResults.hasMore())
            {
                var nextEntry = searchResults.next(); // hits and then goes to timeout
                String dN = nextEntry.getAttribute("distinguishedName").StringValue;
                objectList.Add(dN);
            }

            return objectList;
        }


 LdapSearchResults PrepareSearch(ILdapConnection conn, string searchStart, string searchfilter)
        {
            LdapSearchConstraints constraints = new LdapSearchConstraints();
            constraints.TimeLimit = 30000;

            LdapSearchResults searchResults = conn.Search
            (
                searchStart,
                LdapConnection.SCOPE_SUB,
                searchfilter,
                null,
                false,
                constraints
            );
            return searchResults;
        }

为此,当在结果集上调用 next 时,我总是得到“Novell.Directory.Ldap.LdapException:'没有这样的对象'”。有什么原因我不能像我一样访问它吗?

4

0 回答 0