Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 7a69e7a88f65d279ebe8174a635452dc7c72e4b2 1 parent c9ee1a7
@iarenaza iarenaza authored
Showing with 10 additions and 8 deletions.
  1. +10 −8 lib/ldaplib.php
View
18 lib/ldaplib.php
@@ -247,15 +247,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);
Please sign in to comment.
Something went wrong with that request. Please try again.