|
|
|
@ -23,11 +23,19 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) { |
|
|
|
|
ldap_start_tls($ldapconn) |
|
|
|
|
or error_die($ldapconn, "cannot start LDAP TLS"); |
|
|
|
|
if ($ldapbind = @ldap_bind($ldapconn, $checkuser.'='.$tstusername.','.$ldapbase, $password)) { |
|
|
|
|
ldap_bind($ldap, 'username', 'password'); |
|
|
|
|
$search = ldap_search($ldapconn, 'base_dn', 'search_filter', array('mail', 'cn')); |
|
|
|
|
$data = ldap_get_entries($ldap, $search); |
|
|
|
|
$search = ldap_search($ldapconn, $ldapbase, $checkuser.'='.$tstusername, array('mail\ |
|
|
|
|
', 'cn')); |
|
|
|
|
$data = ldap_get_entries($ldapconn, $search); |
|
|
|
|
ldap_close($ldapconn); |
|
|
|
|
$username = $tstusername; |
|
|
|
|
$email = array('count' => 1, 0 => $username.'@'.$_SERVER[HTTP_HOST]); |
|
|
|
|
$fullname = $username; |
|
|
|
|
if ($data['count']==1) { |
|
|
|
|
if (isset($data[0]['mail'])) |
|
|
|
|
$email = $data[0]['mail']; |
|
|
|
|
if (isset($data[0]['cn'][0])) |
|
|
|
|
$fullname = $data[0]['cn'][0]; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
error_log("user login failed: ".$checkuser.'='.$tstusername.','.$ldapbase); |
|
|
|
|
error_log(ldap_error($ldapconn)); |
|
|
|
|