0

Hey there, I'm writing a PHP application that will use an LDAP server to authenticate. The LDAP server requires me to use a privileged DN/bindDN before I can authenticate my user.

I can do the first bind, using the privileged user settings provided, but then how do I authenticate my user? I see an ldap_compare function in PHP that I could use to compare the username and password provided by the user? Or do something different altogether.

Thanks

David

2
Contributors
1
Reply
4
Views
7 Years
Discussion Span
Last Post by kireol
0

every ldap server is a bit different, however, here's mine

$bindAs = "uid=" . $username . ,ou=Users,dc=yourdc,dc=com";
$ldapbind = @ldap_bind ($ldapconn, $bindAs, $password);
            
if ($ldapbind !== TRUE) 
{
ldap_close ($ldapconn);
return FALSE;
}

and to take it a step further, if you want to get that users attributes

$dn = 'ou=Users,dc=yourdc,dc=com';
            $filter = 'uid=' . $username;
            $attribs = array ('sambaacctflags', 'displayname', 'mail', 'uidnumber');
            $match = ldap_list ($ldapconn, $dn, $filter, $attribs);
            $info = ldap_get_entries ($ldapconn, $match);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.