Browse files

MDL-42723: Hide and handle LDAP error when user not in context being …

…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...
1 parent 6758c0f commit bcad5fa2de1f7fea2c3d57695d29b204ad2e5ce4 @iarenaza iarenaza committed Nov 3, 2013
Showing with 10 additions and 8 deletions.
  1. +10 −8 lib/ldaplib.php
View
18 lib/ldaplib.php
@@ -241,15 +241,17 @@ function ldap_find_userdn($ldapconnection, $username, $contexts, $objectclass, $
}
if ($search_sub) {
- if (!$ldap_result = @ldap_search($ldapconnection, $context,
- '(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))',
- array($search_attrib))) {
- break; // Not found in this context.
- }
+ $ldap_result = @ldap_search($ldapconnection, $context,
+ '(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))',
+ array($search_attrib));
} else {
- $ldap_result = ldap_list($ldapconnection, $context,
- '(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))',
- array($search_attrib));
+ $ldap_result = @ldap_list($ldapconnection, $context,
+ '(&'.$objectclass.'('.$search_attrib.'='.ldap_filter_addslashes($username).'))',
+ array($search_attrib));
+ }
+
+ if (!$ldap_result) {
+ continue; // Not found in this context.
}
$entry = ldap_first_entry($ldapconnection, $ldap_result);

0 comments on commit bcad5fa

Please sign in to comment.