Authenticate user in OpenLDAP with username and password



I need to validate a user with username and password against our
OpenLDAP active directory. This is my code:

Private bool ValidateUser (string username, string password)
{
DirectoryEntry userEntry = new DirectoryEntry(
ldapPath, username, password,
AuthenticationTypes.Anonymous);
//Bind to the native AdsObject to force authentication.

Object obj = userEntry.NativeObject;
DirectorySearcher search = new
DirectorySearcher(userEntry);
search.Filter = "(cn=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (result != null)
return true;
else
return false;
}

The problem is, it returns also true if the username is correct, but
the password is false.
It looks like the user is located but not authenthicated.

I have already tried with several AuthenthicationTypes:
I get an exeption "invalid dn-syntax" for AuthenthicationTypes.None,
AuthenthicationTypes.Delegation, AuthenthicationTypes.FastBind,
AuthenthicationTypes.ReadOnlyServer, AuthenthicationTypes.Sealing.

I get an exception "Die angeforderte Authentifizierungsmethode wird
durch den Server nicht unterstützt" (authenthication method not
supported by server) for AuthenthicationTypes.Secure or if I don't
specify an AuthenthicationType.

Any help is appreciated!
Dorrit

.



Relevant Pages

  • Re: ADAM proxy authentication + Old password still working after resetPassword
    ... > maintained at AD and it acts as the authentication source. ... > entry = new DirectoryEntry(userDN, userLoginName, password, ... > public bool ResetPassword(string username, string password) ...
    (microsoft.public.windows.server.active_directory)
  • Authenticate user in OpenLDAP with username and password
    ... I need to validate a user with username and password against our ... Private bool ValidateUser (string username, ... DirectoryEntry userEntry = new DirectoryEntry( ... //Bind to the native AdsObject to force authentication. ...
    (microsoft.public.dotnet.general)
  • Re: Authenticate user in OpenLDAP with username and password
    ... I need to validate a user with username and password against our ... Private bool ValidateUser (string username, ... DirectoryEntry userEntry = new DirectoryEntry( ... //Bind to the native AdsObject to force authentication. ...
    (microsoft.public.dotnet.languages.csharp)
  • Authenticate user in OpenLDAP with username and password
    ... I need to validate a user with username and password against our ... Private bool ValidateUser (string username, ... DirectoryEntry userEntry = new DirectoryEntry( ... //Bind to the native AdsObject to force authentication. ...
    (microsoft.public.dotnet.framework)
  • Re: How to fetch attributes of LDAP entry?
    ... > When you create the DirectoryEntry object you do so with a username ... This call doesn't attach to the AD with a bad username ... public bool IsAuthenticated(String domain, String username, String pwd) ... object but then it seems that he doesn't search for any authentication, ...
    (microsoft.public.dotnet.framework.aspnet)