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