简体   繁体   中英

Search Active Directory without using LDAP

I am using C# in VS2008 in a WinXP/Win7/WinServer2003 environment.

Is there a way to search the active directory without involving LDAP?

I have users created in Active Directory but when I search using this

        DirectorySearcher dirSearcher = new DirectorySearcher(
            new DirectoryEntry("LDAP://DC=kmmnet,DC=com"),
            "(objectClass=user)",
            new string[] { "sAMAccountName", "displayname", "givenname", "sn" });
        foreach (SearchResult s in dirSearcher.FindAll())
        {
            System.DirectoryServices.PropertyCollection p = s.GetDirectoryEntry().Properties;
        }

it cannot find some of the users.

thanks Shawn

Try bumping the PageSize attribute up from its default of zero:

dirSearcher.PageSize = 9000;

Any non-zero value for PageSize will cause paging to occur, so that you will receive all results (in batches equal to the PageSize).

You can also try filtering the search more (eg, exclude inactive users, etc.).

And, there is an upper limit on the number of results which a directory server will return in response to an LDAP query. This limit is controlled and set by an administrator on the domain. I believe the default is 1000.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM