Page MenuHomePhabricator

D7679.id17337.diff
No OneTemporary

D7679.id17337.diff

Index: src/auth/PhutilAuthAdapterLDAP.php
===================================================================
--- src/auth/PhutilAuthAdapterLDAP.php
+++ src/auth/PhutilAuthAdapterLDAP.php
@@ -218,7 +218,18 @@
$this->bindLDAP($conn, $distinguished_name, $login_pass);
- return $this->searchLDAPForUser($this->searchAttribute, $login_user);
+ $result = $this->searchLDAPForUser($this->searchAttribute, $login_user);
+ if (!$result) {
+ // This is unusual (since the bind succeeded) but we've seen it at least
+ // once in the wild. Raise an explicit exception since we'll fail a
+ // typehint if we don't return an array here.
+ throw new Exception(
+ pht(
+ 'LDAP: Failed to retrieve record for user "%s" when searching.',
+ $login_user));
+ }
+
+ return $result;
}
private function establishConnection() {
@@ -360,7 +371,7 @@
return $results;
}
- private function raiseConnectionException($conn, $message, $is_bind = false) {
+ private function raiseConnectionException($conn, $message) {
$errno = @ldap_errno($conn);
$error = @ldap_error($conn);
@@ -397,8 +408,7 @@
if (!$ok) {
$this->raiseConnectionException(
$conn,
- pht("Failed to bind to LDAP server (as user '%s').", $user),
- $is_bind = true);
+ pht("Failed to bind to LDAP server (as user '%s').", $user));
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 20, 3:15 AM (4 h, 34 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6622382
Default Alt Text
D7679.id17337.diff (1 KB)

Event Timeline