I'm trying to determine why using LDAP and DirectoryServices is extremely slow in some cases and timeouts in others. The entire code of my test application (that I've extracted from our C#/.NET 3.0 app) is:
public void LoginButtonClick(object sender, RoutedEventArgs e)
DirectoryEntry entry = new DirectoryEntry(@"LDAP://QFTI",
//this forces an authentication underneath.
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + "mike.cullingham" + ")";
SearchResult result = search.FindOne();
if (null == result)
// do something...
The "entry.NativeObject" line either returns after 15/20 seconds or takes 4 minutes and then throws the COMException "This operation returned because the timeout period expired." But even if it makes it past this line, it takes an extremely long time or timeouts for the "search.FindOne()" call. It used to work well on my computer (sub-second response time / line), and continues to work well on other computers.
Unfortunately, I'm not the author of the original code and only know the little about LDAP that I've learned from a few hours of internet searches over the last few days.
I have no trouble logging into our network. We've tried other users on this machine with the same results. I've also swapped network cables with another laptop and the other laptop runs the code really quickly.
I'm assuming that something has changed on my machine, but can't think of what that might be. My computer is running Vista, and the slowdown seemed to coincide with a trip to our UK office (regularly based in Calgary), if that helps. Any ideas of what might be causing this, or what I can try to further diagnose the issue?
Tuesday, June 30, 2009 9:11 PM
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.