Last post Apr 27, 2012 09:36 AM by coolblue
Apr 27, 2012 09:36 AM|coolblue|LINK
I have the following code to get records from AD and it is acting odd. It seems to randomly speed up and slow down (ie sometimes it takes around 25 ms to run other times it takes 800ms!)
To make things even stranger, if I put a break point after the code and then run it it takes say 800ms to run, then if I drag the execution back up to just before the code and then re-run it then takes 25ms!
Is it my code that is dodgy or is it AD being rubbish?
The code is a s follows:
DirectoryEntry dirEntManager = new DirectoryEntry("LDAP://" + managerConnection);
DirectorySearcher searchManager = new DirectorySearcher(dirEntManager);
searchManager.Filter = "(&(objectCategory=person)(objectClass=user))";
SearchResult resultManager = searchManager.FindOne();
DirectoryEntry entManager = resultManager.GetDirectoryEntry();
emp.ManagerID = GetSafeInt(entManager.Properties["employeenumber"].Value);
emp.ManagerID = 0;