LDAP Authentication - Lightweight Directory Access Protocol

Using the below function we can authenticate the user using LDAP.

LDAP is a Lightweight Directory Access Protocol it is an Internet protocol that email and other programs use to look up information from a server user.

LDAP is an application protocol for accessing and maintaining distributed directory information services over an Internet Protocol (IP) network.

LDAP is defined in terms of ASN.1 and transmitted using BER.

using System.DirectoryServices;

public static bool IsLDAPAuthenticate(string userName, string password, string domainName, out string errorMessage)

{

bool IsAuthenticate = false;

errorMessage = string.Empty;

try

{

DirectoryEntry LDAPEntry = new DirectoryEntry("LDAP://" + domainName, userName, password);

object nativeObject = LDAPEntry.NativeObject;

IsAuthenticate = true;

LDAPEntry.Close();

}

catch (Exception exception)

{

errorMessage = String.Format("{0}({1})", exception.Message, domainName);

}

return IsAuthenticate;

}


Submitted By Nipesh Shah @ 10/4/2011 5:50:08 PM

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...