From: paca70 Date: Mon, 8 Nov 2004 18:13:00 +0000 (+0000) Subject: Allow config how aliases are derefered. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8021cc54c11c7ec67d84ff61e7752234b81f255b;p=moodle.git Allow config how aliases are derefered. --- diff --git a/auth/ldap/config.html b/auth/ldap/config.html index 3844f412e0..f45a650e34 100644 --- a/auth/ldap/config.html +++ b/auth/ldap/config.html @@ -5,6 +5,7 @@ optional_variable($config->ldap_user_type, ""); optional_variable($config->ldap_user_attribute, ""); optional_variable($config->ldap_search_sub, ""); + optional_variable($config->ldap_opt_deref, ""); optional_variable($config->ldap_bind_dn, ""); optional_variable($config->ldap_bind_pw, ""); optional_variable($config->ldap_version, "2"); @@ -163,6 +164,21 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there? + +

ldap_opt_deref: + + ldap_opt_deref, LDAP_DEREF_NEVER); + if (isset($err["ldap_opt_deref"])) formerr($err["ldap_opt_deref"]); + ?> + + + + + + diff --git a/auth/ldap/lib.php b/auth/ldap/lib.php index abbfb73739..8a2005c0bf 100644 --- a/auth/ldap/lib.php +++ b/auth/ldap/lib.php @@ -1094,7 +1094,7 @@ function auth_ldap_connect($binddn='',$bindpwd=''){ foreach ($urls as $server){ $connresult = ldap_connect($server); //ldap_connect returns ALWAYS true - + if (!empty($CFG->ldap_version)) { ldap_set_option($connresult, LDAP_OPT_PROTOCOL_VERSION, $CFG->ldap_version); } @@ -1105,8 +1105,12 @@ function auth_ldap_connect($binddn='',$bindpwd=''){ } else { //bind anonymously $bindresult=@ldap_bind($connresult); - } - + } + + if (isset($CFG->ldap_opt_deref)) { + ldap_set_option($connresult, LDAP_OPT_DEREF, $CFG->ldap_opt_deref); + } + if ($bindresult) { return $connresult; } @@ -1219,9 +1223,7 @@ function auth_ldap_get_userlist($filter="*") { if ($CFG->ldap_search_sub) { //use ldap_search to find first user from subtree - $ldap_result = ldap_search($ldapconnection, $context, - $filter, - array($CFG->ldap_user_attribute)); + $ldap_result = ldap_search($ldapconnection, $context,$filter,array($CFG->ldap_user_attribute)); } else { //search only in this context $ldap_result = ldap_list($ldapconnection, $context,