Skip to content

Commit

Permalink
MDL-42723: Hide and handle LDAP error when user not in context being …
Browse files Browse the repository at this point in the history
…checked

MDL-41304 only fixed the case when 'Search subcontext' is enabled. We need to
fix the case when it's not enabled too.

While silencing errors with an @ should be avoided if possible, there's no
other way to prevent the warnings in this case.
  • Loading branch information
iarenaza committed Nov 5, 2013
1 parent c9ee1a7 commit 7a69e7a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/ldaplib.php
Expand Up @@ -247,15 +247,17 @@ function ldap_find_userdn($ldapconnection, $username, $contexts, $objectclass, $
} }


if ($search_sub) { if ($search_sub) {
if (!$ldap_result = @ldap_search($ldapconnection, $context, $ldap_result = @ldap_search($ldapconnection, $context,
'(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))', '(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))',
array($search_attrib))) { array($search_attrib));
break; // Not found in this context.
}
} else { } else {
$ldap_result = ldap_list($ldapconnection, $context, $ldap_result = @ldap_list($ldapconnection, $context,
'(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))', '(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))',
array($search_attrib)); array($search_attrib));
}

if (!$ldap_result) {
continue; // Not found in this context.
} }


$entry = ldap_first_entry($ldapconnection, $ldap_result); $entry = ldap_first_entry($ldapconnection, $ldap_result);
Expand Down

0 comments on commit 7a69e7a

Please sign in to comment.