From 7637b49aac7940c3356a281fa247277e3ac6cc70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Mon, 27 Feb 2017 23:29:04 +0000 Subject: [PATCH] make cn or uid configurable --- etc/authentication.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/etc/authentication.php b/etc/authentication.php index d42e0a1..9a075ae 100644 --- a/etc/authentication.php +++ b/etc/authentication.php @@ -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; }