modifs.mineures sans commentaires
This commit is contained in:
parent
612b946db6
commit
37ac992222
|
@ -5,10 +5,12 @@ use nur\b\UserException;
|
||||||
|
|
||||||
class LdapException extends UserException {
|
class LdapException extends UserException {
|
||||||
/** @param $r ?resource */
|
/** @param $r ?resource */
|
||||||
static function check(string $message, $r, $value) {
|
static function check(string $message, $r, $value, ?int $allow_errno=null) {
|
||||||
if ($value !== false) return $value;
|
if ($value !== false) return $value;
|
||||||
if ($r !== null) {
|
if ($r !== null) {
|
||||||
throw new self($message, ldap_errno($r), null, ldap_error($r));
|
$errno = ldap_errno($r);
|
||||||
|
if ($allow_errno !== null && $errno === $allow_errno) return $value;
|
||||||
|
throw new self($message, $errno, null, ldap_error($r));
|
||||||
} else {
|
} else {
|
||||||
throw new self($message);
|
throw new self($message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,17 +157,16 @@ class LdapSearch extends Parametrable implements IteratorAggregate {
|
||||||
elseif ($scope == self::SCOPE_BASE) $rr = @ldap_read(...$args);
|
elseif ($scope == self::SCOPE_BASE) $rr = @ldap_read(...$args);
|
||||||
else throw ValueException::invalid_value($scope, "scope");
|
else throw ValueException::invalid_value($scope, "scope");
|
||||||
|
|
||||||
// pas trouvé
|
$rr = LdapException::check("search", $conn, $rr, 32);
|
||||||
if ($rr === false && ldap_errno($conn) == 32) return;
|
if ($rr === false) return; // pas trouvé
|
||||||
$rr = LdapException::check("search", $conn, $rr);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$er = LdapException::check("first_entry", $conn, ldap_first_entry($conn, $rr));
|
$er = LdapException::check("first_entry", $conn, ldap_first_entry($conn, $rr), 32);
|
||||||
while ($er !== false) {
|
while ($er !== false) {
|
||||||
$dn = ldap_get_dn($conn, $er);
|
$dn = ldap_get_dn($conn, $er);
|
||||||
$entry = ldap_get_attributes($conn, $er);
|
$entry = ldap_get_attributes($conn, $er);
|
||||||
yield $dn => $entry;
|
yield $dn => $entry;
|
||||||
$er = LdapException::check("next_entry", $conn, ldap_next_entry($conn, $er));
|
$er = LdapException::check("next_entry", $conn, ldap_next_entry($conn, $er), 32);
|
||||||
}
|
}
|
||||||
} catch (StopException $e) {
|
} catch (StopException $e) {
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue