Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mail condition to user info methods #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/adLDAP/classes/adLDAPUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,17 @@ 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; }

if ($isGUID === true) {
$username = $this->adldap->utilities()->strGuidToHex($username);
$filter = "objectguid=" . $username;
}
else if ($isMail === true) {
$filter = "mail=". $username;
}
else if (strpos($username, "@")) {
$filter = "userPrincipalName=" . $username;
}
Expand Down Expand Up @@ -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);
Expand Down