X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/0821672e70cf9eb81091032514634b299cc5900b..refs/pull/205/head:/app/Services/LdapService.php diff --git a/app/Services/LdapService.php b/app/Services/LdapService.php index d33f8c378..b7f101ad2 100644 --- a/app/Services/LdapService.php +++ b/app/Services/LdapService.php @@ -36,6 +36,7 @@ class LdapService public function getUserDetails($userName) { $ldapConnection = $this->getConnection(); + $this->bindSystemUser($ldapConnection); // Find user $userFilter = $this->buildFilter($this->config['user_filter'], ['user' => $userName]); @@ -45,7 +46,7 @@ class LdapService $user = $users[0]; return [ - 'uid' => $user['uid'][0], + 'uid' => (isset($user['uid'])) ? $user['uid'][0] : $user['dn'], 'name' => $user['cn'][0], 'dn' => $user['dn'], 'email' => (isset($user['mail'])) ? $user['mail'][0] : null @@ -93,7 +94,7 @@ class LdapService $ldapBind = $this->ldap->bind($connection, $ldapDn, $ldapPass); } - if (!$ldapBind) throw new LdapException('LDAP access failed using ' . $isAnonymous ? ' anonymous bind.' : ' given dn & pass details'); + if (!$ldapBind) throw new LdapException('LDAP access failed using ' . ($isAnonymous ? ' anonymous bind.' : ' given dn & pass details')); } /** @@ -121,7 +122,7 @@ class LdapService // Set any required options if ($this->config['version']) { - $this->ldap->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $this->config['version']); + $this->ldap->setVersion($ldapConnection, $this->config['version']); } $this->ldapConnection = $ldapConnection;