Skip to content

Commit

Permalink
Merged from MOODLE_14_STABLE - Better handling of trailing semicolons…
Browse files Browse the repository at this point in the history
… and spaces in LDAP configs. Fixes a regression from 1.4.2, plus fixed typo: == should be =
  • Loading branch information
martinlanghoff committed Mar 1, 2005
1 parent e0003df commit cecfc11
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion auth/ldap/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ function auth_get_users($filter='*', $dontlistcreated=false) {


foreach ($contexts as $context) {

$context = trim($context);
if (empty($context)) {
continue;
}

if ($CFG->ldap_search_sub) {
//use ldap_search to find first user from subtree
Expand Down Expand Up @@ -391,6 +396,10 @@ function auth_sync_users ($bulk_insert_records = 1000, $do_updates=1) {
$fresult = array();
$count = 0;
foreach ($contexts as $context) {
$context = trim($context);
if (empty($context)) {
continue;
}
begin_sql();
if ($CFG->ldap_search_sub) {
//use ldap_search to find first user from subtree
Expand Down Expand Up @@ -1183,6 +1192,10 @@ function auth_ldap_isgroupmember ($username='', $groupdns='') {
$groups = explode(";",$groupdns);

foreach ($groups as $group){
$group = trim($group);
if (empty($group)) {
continue;
}
//echo "Checking group $group for member $username\n";
$search = @ldap_read($ldapconnection, $group, '('.$CFG->ldap_memberattribute.'='.$username.')', array($CFG->ldap_memberattribute));
if (ldap_count_entries($ldapconnection, $search)) {$info = auth_ldap_get_entries($ldapconnection, $search);
Expand Down Expand Up @@ -1228,6 +1241,11 @@ function auth_ldap_connect($binddn='',$bindpwd=''){
$urls = explode(";",$CFG->ldap_host_url);

foreach ($urls as $server){
$url = trim($url);
if (empty($url)) {
continue;
}

$connresult = ldap_connect($server);
//ldap_connect returns ALWAYS true

Expand Down Expand Up @@ -1284,7 +1302,10 @@ function auth_ldap_find_userdn ($ldapconnection, $username){

foreach ($ldap_contexts as $context) {

$context == trim($context);
$context = trim($context);
if (empty($context)) {
continue;
}

if ($CFG->ldap_search_sub){
//use ldap_search to find first user from subtree
Expand Down Expand Up @@ -1360,6 +1381,11 @@ function auth_ldap_get_userlist($filter="*") {

foreach ($contexts as $context) {

$context = trim($context);
if (empty($context)) {
continue;
}

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));
Expand Down

0 comments on commit cecfc11

Please sign in to comment.