From 0d80102c4837ccd01edfec948b59be97385c6a16 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 19 Jan 2015 21:49:01 -0500 Subject: Minor code improvements for the pull-request --- app/Auth/Ldap.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/Auth/Ldap.php b/app/Auth/Ldap.php index 22c9fb88..dbf12387 100644 --- a/app/Auth/Ldap.php +++ b/app/Auth/Ldap.php @@ -208,27 +208,31 @@ class Ldap extends Base } /** - * Retrieve info on LDAP user. + * Retrieve info on LDAP user * - * @param resource $ldap LDAP connection * @param string $username Username * @param string $email Email address */ public function lookup($username = null, $email = null) { - if ($username && $email) + if ($username && $email) { $query = '(&('.sprintf(LDAP_USER_PATTERN, $username).')('.sprintf(LDAP_ACCOUNT_EMAIL, $email).')'; - else if ($username) + } + else if ($username) { $query = sprintf(LDAP_USER_PATTERN, $username); - else if ($email) + } + else if ($email) { $query = '('.LDAP_ACCOUNT_EMAIL.'='.$email.')'; - else + } + else { return false; + } // Connect and attempt anonymous bind $ldap = $this->connect(); - if (!is_resource($ldap) || !$this->bind($ldap, null, null)) + if (! is_resource($ldap) || ! $this->bind($ldap, null, null)) { return false; + } // Try to find user $sr = @ldap_search($ldap, LDAP_ACCOUNT_BASE, $query, array(LDAP_ACCOUNT_FULLNAME, LDAP_ACCOUNT_EMAIL, LDAP_ACCOUNT_ID)); @@ -244,7 +248,7 @@ class Ldap extends Base } // User id not retrieved: LDAP_ACCOUNT_ID not properly configured - if (!$username && !isset($info[0][LDAP_ACCOUNT_ID][0])) { + if (! $username && ! isset($info[0][LDAP_ACCOUNT_ID][0])) { return false; } -- cgit v1.2.3