Problemer med LDAP mod W2K
Jeg har noget bøvl med en ASP.Net webapp.Godkendelse af bruger sker med bl.a. AD via LDAP mod den Windows 2000 Server, som er DC.
Koden er stærkt inspireret af http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q316748
Et sted I linket står der:
**************************
Configure IIS for Anonymous Authentication
To configure IIS for anonymous authentication, follow these steps:
1. In IIS, click to select the Anonymous Authentication check box.
2. Make the anonymous account for the application an account that has permission to the Active Directory.
3. Click to clear the Allow IIS To Control Password check box.
The default IUSR_computername account does not have permission to the Active Directory.
**************************
Derfor prøvede jeg med en brugerkonto som er medlem af administrator gruppen på domænet, men uden held.
Hvad gør jeg forkert, mangler eller har jeg misforstået?
Da jeg udvikler på et andet netværk end domænet er det bøvlet at teste, hvorfor jeg har indlagt et antal log-skrivninger i koden. Under koden er de logs som er blevet oprettet under udførslen af koden.
Line 30 er: Object obj = entry.NativeObject;
---------------------------------
public bool IsAuthenticated(String username, String pwd)
{
String domainAndUsername = MLSettings.Instance.GetValueAsString("server:domain") + @"\\" + username;
try
{
DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
Log.CreateLog(Log.Type.Information, "LDAP::IsAuthenticated", "Der blev udført DirectoryEntry(" + _path + ", " + domainAndUsername + ", " + pwd + ");");
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if(null == result)
{
return false;
}
//Update the new path to the user in the directory.
_path = result.Path;
_filterAttribute = (String)result.Properties["cn"][0];
}
catch (Exception ex)
{
Log.CreateLog(Log.Type.Error, "LDAP::IsAuthenticated", "Der opstod en exception: " + ex);
return false;
}
return true;
}
---------------------------------
2005-03-09 14:20:59 Der blev udført DirectoryEntry(srv, uv\mat, <password>);
2005-03-09 14:20:59 Der opstod en exception: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_NativeObject()
at intranet.classes.logon.LdapAuthentication.IsAuthenticated(String username, String pwd) in c:inetpubwwwrootintranetclasseslogonldap.cs:line 30
---------------------------------
