From 33a30ca9e62a5ff1496dd489abee06d5dcf8b02f Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Fri, 26 Aug 2005 04:11:22 +0000 Subject: [PATCH] Merged from MOODLE_15_STABLE - enrol/ldap - fixed default objectclass, and we can now bind non-anonymously --- enrol/ldap/enrol.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/enrol/ldap/enrol.php b/enrol/ldap/enrol.php index b374ac73c73..6f5a56838e9 100755 --- a/enrol/ldap/enrol.php +++ b/enrol/ldap/enrol.php @@ -180,7 +180,7 @@ function sync_enrolments($type, $enrol) { if (!empty($CFG->enrol_ldap_objectclass)){ $ldap_search_pattern='(objectclass='.$CFG->enrol_ldap_objectclass.')'; } else { - $ldap_search_pattern="(objectclass='*')"; + $ldap_search_pattern="(objectclass=*)"; } @@ -441,8 +441,17 @@ function enrol_ldap_connect(){ ldap_set_option($result, LDAP_OPT_PROTOCOL_VERSION, $CFG->enrol_ldap_version); } - return $result; + if (!empty($CFG->enrol_ldap_bind_dn)) { + $bind = ldap_bind( $result, + $CFG->enrol_ldap_bind_dn, + $CFG->enrol_ldap_bind_pw ); + if (!$bind) { + notify("Error in binding to LDAP server"); + trigger_error("Error in binding to LDAP server $!"); + } + } + return $result; } else { notify("LDAP-module cannot connect to server: $CFG->enrol_ldap_host_url"); return false;