I am retrieving a handful of LDAP (Active Directory) properties for about 10,000 users. I know that AD queries aren't the fastest in the world but at the 19 minute mark (almost exactly) the program stops processing and about 15 minutes after that I get the error
A device attached to the system is no longer functioning
on the DirectorySearcher.FindOne()
method.
I don't think I'm doing anything weird in the code but I'm wondering if I need to re-write this to a FindAll()
and then parse though that list.
searcher.Filter = "(sAMAccountName=" + u.LogonName + ")";
string[] properties = new string[]
{
"givenName",
"sn",
"displayName",
"mail",
"physicalDeliveryOfficeName",
"division",
"grpDivision"
};
searcher.PropertiesToLoad.AddRange(properties);
SearchResult result = searcher.FindOne();
It doesn't stop on the same user every time and on the user it does stop on I've checked their attributes for anything that stands out and can't find anything out of the ordinary.
As you can imagine it gets quite tedious debugging in 35 minute increments so I'm hoping someone has seen this before or know about some hidden Active Directory connection time limit.
Thanks!