Showing posts with label User authentication with LDAP server sample code. Show all posts
Showing posts with label User authentication with LDAP server sample code. Show all posts

Monday, March 7, 2011

User authentication with LDAP server sample code

ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$ldapconfig['host'] = xxx.xxx.xxx.xxx';// IP Address
$ldapconfig['port'] = 389; //port(default port is 389)
$ldapconfig['basedn'] ='dc=yyy,dc=yy';

$ds=ldap_connect($ldapconfig['host'], $ldapconfig['port']);

//$dn="uid=".$username.",ou=people,".$ldapconfig['basedn'];
$dn="uid=".charith.",".$ldapconfig['basedn'];
$password='yourdullaa';

if ($bind=ldap_bind($ds, $dn, $password))
{
echo("Login correct");
}
else
{

echo("Unable to bind to server.
");


}