diff --git a/src/auth/PhutilLDAPAuthAdapter.php b/src/auth/PhutilLDAPAuthAdapter.php --- a/src/auth/PhutilLDAPAuthAdapter.php +++ b/src/auth/PhutilLDAPAuthAdapter.php @@ -11,6 +11,7 @@ private $baseDistinguishedName; private $searchAttributes = array(); private $usernameAttribute; + private $emailAttribute; private $realNameAttributes = array(); private $ldapVersion = 3; private $ldapReferrals; @@ -59,6 +60,11 @@ return $this; } + public function setEmailAttribute($email_attribute) { + $this->emailAttribute = $email_attribute; + return $this; + } + public function setRealNameAttributes(array $attributes) { $this->realNameAttributes = $attributes; return $this; @@ -153,6 +159,13 @@ } public function readLDAPRecordEmail(array $record) { + $result = ''; + if ($this->emailAttribute) { + $result = $this->readLDAPData($record, $this->emailAttribute); + } + if (strlen(trim($result))) { + return $result; + } return $this->readLDAPData($record, 'mail'); }