Ask a Question related to ASP.NET Security, Design and Development.
-
tlthompson@west.com #1
Perplexing DirectorySearcher error
Hi,
This seems strange to me and was wondering if anyone had any insight as to
why this fails (for users not on the machine) when the ou is included in the
rootpath for the DirectorySearcher, but works for everyone if it isn't
included?
The code and explanation in commented sections
private void strange()
{
// userdn is actually fetched elsewhere in the program by a different ldap
query
string userdn = "cn=Last\\, First M.,ou=group,ou=site,ou=X,dc=X,dc=Y,dc=Z";
// this is the rootpath for the active directory query
string rootpath = null;
// works if I am on the machine hosting the web app, but fails if I'm not
rootpath = "LDAP://server/ou=X,dc=X,dc=Y,dc=com";
// this rootpath always works (the "ou=X" has been removed)
rootpath = "LDAP://server/dc=X,dc=Y,dc=com";
string [] props = new string[2];
props[0] = "cn";
props[1] = "objectGUID";
DirectoryEntry adroot = new DirectoryEntry(rootpath);
DirectorySearcher dsrch = new DirectorySearcher(adroot,
"(&(objectClass=user)(manager="+userdn+"))",props) ;
// the error occurs on the below line if the first rootpath is used
SearchResultCollection srcoll= dsrch.FindAll();
}
The stacktrace from the error follows:
Server Error in '/StrangeApp' Application.
--------------------------------------------------------------------------------
The specified directory service attribute or value does not exist
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The
specified directory service attribute or value does not exist
Source Error:
Line 49: DirectoryEntry adroot = new DirectoryEntry(rootpath);
Line 50: DirectorySearcher dsrch = new DirectorySearcher(adroot,
"(&(objectClass=user)(manager="+userdn+"))",props) ;
Line 51: SearchResultCollection srcoll= dsrch.FindAll();
Line 52: }
Line 53:
Source File: c:\inetpub\wwwroot\StrangeApp\StrangeClass.aspx.cs Line: 51
Stack Trace:
[COMException (0x8007200a): The specified directory service attribute or
value does not exist]
System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail) +513
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_AdsObj ect() +10
System.DirectoryServices.DirectorySearcher.FindAll (Boolean
findMoreThanOne) +198
System.DirectoryServices.DirectorySearcher.FindAll () +10
StrangeApp.StrangeClass.strange() in
c:\inetpub\wwwroot\StrangeApp\StrangeClass.aspx.cs :51
StrangeApp.StrangeClass.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\StrangeApp\StrangeClass.aspx.cs :171
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
Thanks,
Todd Thompson
tlthompson@west.com Guest
-
DirectorySearcher - SearchResult - User Groups
Hi, I'm having trouble fetching the AD groups a user belongs to after authenticating them against Active Directory. My code is based on the How To... -
Perplexing connection problem - Win2K ASP/Jet DB
I am experiencing a problem with connecting to a MS Jet database (Access 97 mdb file format) via a classic ASP page running under Win2K/IIS server... -
perplexing error posting to php script
At first I thought this error had to do with a timeout problem, but now I am almost certain it has direct bearing on the size of the data that I am... -
An error occurred while try to load the string resources (GetModuleHandle failed with error -2147023888)
Hello, on one of our customers servers we get following error on first ASPX-page: An error occurred while try to load the string resources... -
DirectorySearcher & sorting
I would like to do a search and have the results sorted by property 1 and then by property 2. My first thought had been //set up the searching...



Reply With Quote

