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.
This commit is contained in:
Iñaki Arenaza
2013-11-05 17:13:16 +01:00
parent 6758c0fa99
commit bcad5fa2de
+10 -8
View File
@@ -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);