From e0f5a5be1d44d518a8db4f059998391216d69fdb Mon Sep 17 00:00:00 2001 From: paca70 Date: Mon, 18 Oct 2004 16:33:25 +0000 Subject: [PATCH] Allow auth_ldap_connect() to take binddn ja bindpwd CVS: ---------------------------------------------------------------------- --- auth/ldap/lib.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/auth/ldap/lib.php b/auth/ldap/lib.php index 197b5bf6d6..e1dd0dcc15 100644 --- a/auth/ldap/lib.php +++ b/auth/ldap/lib.php @@ -996,14 +996,26 @@ function auth_ldap_isgroupmember ($username='', $groupdns='') { * * @return connection result */ -function auth_ldap_connect(){ +function auth_ldap_connect($binddn='',$bindpwd=''){ /// connects and binds to ldap-server /// Returns connection result global $CFG; auth_ldap_init(); + + //Select bind password, With empty values use + //ldap_bind_* variables or anonymous bind if ldap_bind_* are empty + if ($binddn == '' AND $bindpwd == '') { + if (!empty($CFG->ldap_bind_dn)){ + $binddn = $CFG->ldap_bind_dn; + } + if (!empty($CFG->ldap_bind_pw)){ + $bindpwd = $CFG->ldap_bind_pw; + } + } + $urls = explode(";",$CFG->ldap_host_url); - + foreach ($urls as $server){ $connresult = ldap_connect($server); //ldap_connect returns ALWAYS true @@ -1012,9 +1024,9 @@ function auth_ldap_connect(){ ldap_set_option($connresult, LDAP_OPT_PROTOCOL_VERSION, $CFG->ldap_version); } - if ($CFG->ldap_bind_dn){ + if (!empty($binddn)){ //bind with search-user - $bindresult=@ldap_bind($connresult, $CFG->ldap_bind_dn,$CFG->ldap_bind_pw); + $bindresult=@ldap_bind($connresult, $binddn,$bindpwd); } else { //bind anonymously $bindresult=@ldap_bind($connresult); -- 2.39.5