views:

287

answers:

1

I wrote one webservice in ASP.net. I need to authenticate the webservice with the local network userid and password. I am checking this value using LDAP. How can I make this without minimal coding.

A: 

Check out System.DirectoryServices.Protocols and the LdapConnection class.

This namespace is more general for LDAP than the System.DirectoryServices namespace which is more specific to Active Directory. I've found that it's also much better to use if you need to get other attributes specific to LDAP such as pwdChangedTime.

You can can establish an LDAP connection and use the Bind function to check if it can bind to the specific dn of the user given the password.

ldapConnection.Credential = new NetworkCredential(dn, password);
try
{
     ldapConnection.Bind();
}
catch (Exception exc)
{
     // return failurecode depending on exception
}
// return successcode
Turnkey