summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-07-08 15:47:43 -0300
committerFrédéric Guillot <fred@kanboard.net>2014-07-08 15:47:43 -0300
commitb84f60babc0e3ebb904af04b8139bbd048895e44 (patch)
tree34109ab53132530c8f3d560746dba726a9c584b4 /app/Model
parentba93061f4d844214851d5a22b5a34022ce37e925 (diff)
Minor changes for the LDAP model
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Ldap.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/Model/Ldap.php b/app/Model/Ldap.php
index 4e605eb2..dabcd5ff 100644
--- a/app/Model/Ldap.php
+++ b/app/Model/Ldap.php
@@ -24,8 +24,8 @@ class Ldap extends Base
die('The PHP LDAP extension is required');
}
- if (!LDAP_SSL_VERIFY) {
- //Skip SSL certificate verification
+ // Skip SSL certificate verification
+ if (! LDAP_SSL_VERIFY) {
putenv('LDAPTLS_REQCERT=never');
}
@@ -38,19 +38,24 @@ class Ldap extends Base
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
- if (!@ldap_bind($ldap, LDAP_USERNAME, LDAP_PASSWORD)) {
+ if (! @ldap_bind($ldap, LDAP_USERNAME, LDAP_PASSWORD)) {
die('Unable to bind to the LDAP server: "'.LDAP_SERVER.'"');
}
- $sr = ldap_search($ldap, LDAP_ACCOUNT_BASE, sprintf(LDAP_USER_PATTERN, $username), array(LDAP_ACCOUNT_FULLNAME, LDAP_ACCOUNT_EMAIL));
+ $sr = @ldap_search($ldap, LDAP_ACCOUNT_BASE, sprintf(LDAP_USER_PATTERN, $username), array(LDAP_ACCOUNT_FULLNAME, LDAP_ACCOUNT_EMAIL));
+
+ if ($sr === false) {
+ return false;
+ }
+
$info = ldap_get_entries($ldap, $sr);
+
+ // User not found
if (count($info) == 0 || $info['count'] == 0) {
- //User not found
return false;
}
if (@ldap_bind($ldap, $info[0]['dn'], $password)) {
- error_log("Bind to user OK");
return $this->create($username, $info[0][LDAP_ACCOUNT_FULLNAME][0], $info[0][LDAP_ACCOUNT_EMAIL][0]);
}