Shawn Baker
Shawn Baker

Reputation: 28

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

Upvotes: 0

Views: 521

Answers (1)

JMC
JMC

Reputation: 930

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 (e.g., 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.

Upvotes: 2

Related Questions