I have been working on a project to search for 250,000 different
records in ActiveDirectory . The process takes a long time and I have
tried everything to make it faster. Currently using
System.Director yServices, the calls to the server to search for one
record is currently taking 2-3 seconds. I tried to throw these
requests in the ThreadPool, but was having locking issues on the call
to:
DirectorySearch er.FindOne();
Recently I discovered that the new System.Director yServices.Proto cols
in .NET 2.0 is Thread Safe. I rewrote all my code and was surprised
to see that a call to:
LDAPConnection. SendRequest(req uest);
takes 30-60 seconds. Ten times as long as the old way. What am I
missing? Here is the psuedocode showing how I am searching.
Obviously, I'm no expert in searching against ActiveDirectory , but am
trying my best to find good info on the subject.
string target = "dc=region, dc=server, dc=com";
LdapConnection connection = new LdapConnection( server);
string[] attributes = new string[] { "a", "b", "c", "d" };
string filter = String.Format(" (&(objectCatego ry=person)
(objectClass=us er)(employeeID= {0}))", ID);
SearchRequest request = new SearchRequest(t arget, filter,
SearchScope.Sub tree, attributes);
request.SizeLim it = 1;
DateTime start = DateTime.Now;
SearchResponse response;
try
{
response =
(SearchResponse )connection.Sen dRequest(reques t);
}