DirectorySearcher Question

From: Bob Willer (bobw@liquidmatrix.com)
Date: 11/21/02


From: "Bob Willer" <bobw@liquidmatrix.com>
Date: Thu, 21 Nov 2002 12:47:12 -0500


I have two machines: One is running .NET Server 2003, one is running Windows
XP. Both are running the 1.1 framework beta. Both machines have identical
websites running on them. They both have the following block of code in an
assembly called by an asp.net page:

DirectoryEntry srcRoot = new DirectoryEntry(LDAP://MYDOMAIN);
DirectorySearcher search = new DirectorySearcher();
search.SearchRoot = srcRoot;
search.Filter = "(sAMAccountName=bobw)";
SearchResult res = search.FindOne();

This code works fine on the .NET Server machine. On my XP machine it
res=null. While trying to debug this, I have found a couple curious things:

1) If I run this code from a console app (not within the context of ASP.NET)
it runs correctly on both machines.
2) When running it under the debugger (within the asp.net application), when
the constructor of DirectorySearcher() is called in the second line, the
searchRoot property is null on my XP box, but is set to a instance of
DirectoryEntry on my .NET Server box. This only happens when running in the
asp.net application. When running from the console app, it is null on both
machines.

So the first question is why doesn't this work on my XP box running under
ASP.NET? And second, why would the constructor return different information
in the .NET server/ASP.NET version?

Any help would be appreciated!
Thanks
BW



Relevant Pages