make cn or uid configurable
This commit is contained in:
		@@ -3,8 +3,9 @@ $realm = "MY REALM HERE";
 | 
			
		||||
$ldaphost = "my.ldap.host";
 | 
			
		||||
$ldaptls = "yes";
 | 
			
		||||
$ldapbase = "dc=my,dc=server,dc=com";
 | 
			
		||||
$checkuser = "cn";
 | 
			
		||||
function basicAuth() {
 | 
			
		||||
    header('WWW-Authenticate: Basic realm="'.$REALM.'"');
 | 
			
		||||
    header('WWW-Authenticate: Basic realm="'.$realm.'"');
 | 
			
		||||
    header('HTTP/1.0 401 Unauthorized');
 | 
			
		||||
    exit;
 | 
			
		||||
}
 | 
			
		||||
@@ -20,7 +21,7 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
 | 
			
		||||
    if ($ldaptls!="no" && $ldaptls!=0 && $ldaptlS)
 | 
			
		||||
        ldap_start_tls($ldapconn)
 | 
			
		||||
            or error_die($ldapconn, "cannot start LDAP TLS");
 | 
			
		||||
    $ldapbind = @ldap_bind($ldapconn, 'uid='.$tstusername.','.$ldapbase, $password)
 | 
			
		||||
    $ldapbind = @ldap_bind($ldapconn, $checkuser.'='.$tstusername.','.$ldapbase, $password)
 | 
			
		||||
        or basicAuth();
 | 
			
		||||
    $username = $tstuserbname;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user