From c023fb48dcb759b8402855039fef8182329456e6 Mon Sep 17 00:00:00 2001 From: Dylan Jacob Date: Mon, 8 Sep 2014 10:50:33 -0500 Subject: [PATCH 1/2] Adding mail condition to user info methods Added isMail flag to adLDAPUsers->info and adLDAPUsers->infocollection Added condition and filter to the info method --- lib/adLDAP/classes/adLDAPUsers.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/adLDAP/classes/adLDAPUsers.php b/lib/adLDAP/classes/adLDAPUsers.php index c3ea8c6..6dbb957 100644 --- a/lib/adLDAP/classes/adLDAPUsers.php +++ b/lib/adLDAP/classes/adLDAPUsers.php @@ -208,7 +208,7 @@ public function groups($username, $recursive = NULL, $isGUID = false) { * @param bool $isGUID Is the username passed a GUID or a samAccountName * @return array */ - public function info($username, $fields = NULL, $isGUID = false) { + public function info($username, $fields = NULL, $isGUID = false, $isMail = false) { if ($username === NULL) { return false; } if (!$this->adldap->getLdapBind()) { return false; } @@ -216,6 +216,9 @@ public function info($username, $fields = NULL, $isGUID = false) { $username = $this->adldap->utilities()->strGuidToHex($username); $filter = "objectguid=" . $username; } + if ($isMail === true) { + $filter = "mail=". $username; + } else if (strpos($username, "@")) { $filter = "userPrincipalName=" . $username; } @@ -261,11 +264,11 @@ public function info($username, $fields = NULL, $isGUID = false) { * @param bool $isGUID Is the username passed a GUID or a samAccountName * @return mixed */ - public function infoCollection($username, $fields = NULL, $isGUID = false) { + public function infoCollection($username, $fields = NULL, $isGUID = false, $isMail = false) { if ($username === NULL) { return false; } if (!$this->adldap->getLdapBind()) { return false; } - $info = $this->info($username, $fields, $isGUID); + $info = $this->info($username, $fields, $isGUID, $isMail); if ($info !== false) { $collection = new \adLDAP\collections\adLDAPUserCollection($info, $this->adldap); From 8de1a667f89aac1e734653019b3375c94fbc2d3c Mon Sep 17 00:00:00 2001 From: Dylan Jacob Date: Mon, 8 Sep 2014 10:56:04 -0500 Subject: [PATCH 2/2] changed mail condition to else if changed from `if isMail then filter` to `else if isMail then filter` --- lib/adLDAP/classes/adLDAPUsers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/adLDAP/classes/adLDAPUsers.php b/lib/adLDAP/classes/adLDAPUsers.php index 6dbb957..be7ad64 100644 --- a/lib/adLDAP/classes/adLDAPUsers.php +++ b/lib/adLDAP/classes/adLDAPUsers.php @@ -216,7 +216,7 @@ public function info($username, $fields = NULL, $isGUID = false, $isMail = false $username = $this->adldap->utilities()->strGuidToHex($username); $filter = "objectguid=" . $username; } - if ($isMail === true) { + else if ($isMail === true) { $filter = "mail=". $username; } else if (strpos($username, "@")) {