Permalink
Browse files

Allow auth_ldap_connect() to take binddn ja bindpwd

 CVS: ----------------------------------------------------------------------
  • Loading branch information...
1 parent 169fc66 commit e0f5a5be1d44d518a8db4f059998391216d69fdb paca70 committed Oct 18, 2004
Showing with 16 additions and 4 deletions.
  1. +16 −4 auth/ldap/lib.php
View
@@ -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);

0 comments on commit e0f5a5b

Please sign in to comment.