Hej,
Jag försöker göra en LDAP förfrågan, men får följande fel:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Unknown error (0x80005000)
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: Unknown error (0x80005000)
Source Error:
Line 28:
Line 29: DirectoryEntry entry = new DirectoryEntry(LDAPpath, "DOMAIN\\HIDDENUSERNAME", "HIDDENPASSWORD");
Line 30: object obj = entry.NativeObject;
Line 31:
Line 32: DirectorySearcher search = new DirectorySearcher(entry);
Source File: c:\Inetpub\wwwroot\Default.master.cs Line: 30
Stack Trace:
[COMException (0x80005000): Unknown error (0x80005000)]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +451
System.DirectoryServices.DirectoryEntry.Bind() +36
System.DirectoryServices.DirectoryEntry.get_NativeObject() +31
_Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Default.master.cs:30
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
Enligt Microsoft så betyder detta felet "The specified directory service attribute or value does not exist", men jag har provat väldigt många olika försök - men inget lyckas.
Följande kod används:
string LDAPpath = "ldap://192.168.1.1:389/OU=Users,OU=Gothenburg,DC=DOMAIN,DC=net";
DirectoryEntry entry = new DirectoryEntry(LDAPpath, "DOMAIN\\HIDDENUSERNAME", "HIDDENPASSWORD");
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "CN=ELIASSON";
SearchResult result = search.FindOne();
Hoppas att vi har någon duktig inom LDAP och ASP.NET som har möjlighet att hjälpa mig.
(P.S - Samtliga namn och ip-adresser är påhittade, men ovanstående källkod är den som används för tillfället.)
Om du ställer din ldap fråga med ett annat verktyg och samma credentials... får du något resultat då ?
Ursäkta mitt sena svar.
Nej, jag får inte samma problem då och följande LDAP fråga fungerar i ett annat program:
ldap://192.168.1.1:389/OU=Users,OU=Gothenburg,DC=DOMAIN,DC=net
Men följande kod fungerar inte:
DirectoryEntry entry = new DirectoryEntry("ldap://192.168.1.1:389/OU=Users,OU=Gothenburg,DC=DOMAIN,DC=net", "DOMAIN\\HIDDENUSERNAME", "HIDDENPASSWORD");
DirectorySearcher search = new DirectorySearcher(entry);
SearchResultCollection results;
results = search.FindAll();
Får felet:
Unknown error (0x80005000)
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: Unknown error (0x80005000)
Source Error:
Line 19: SearchResultCollection results;
Line 20:
Line 21: results = search.FindAll();
Line 22: }
Felet pekar mot rad 19, results = search.FindAll();