Skip to content

Commit

Permalink
Fix LDAP AD login without domain (simply user ID).
Browse files Browse the repository at this point in the history
  • Loading branch information
hardkeo committed Aug 29, 2024
1 parent 92d3698 commit 814f109
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/Domain/Ldap/Services/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,17 @@ public function bind(string $username = '', string $password = ''): bool
if ($this->directoryType == 'AD') {
$usernameDN = $username;

$bind = ldap_bind($this->ldapConnection, $usernameDN, $passwordBind);
if (str_contains($usernameDN, '@')) {
$bind = ldap_bind($this->ldapConnection, $usernameDN, $passwordBind);
} else {
$bind = ldap_bind($this->ldapConnection, $usernameDN . "@" . $this->ldapDomain, $passwordBind);
}

if ($bind) {
return true;
}

$bind = ldap_bind($this->ldapConnection, $usernameDN . "@" . $this->ldapDomain, $passwordBind);
//OL requires distinguished name login
} else {
//OL requires distinguished name login
$usernameDN = $this->ldapKeys->username . "=" . $username . "," . $this->ldapDn;

$bind = ldap_bind($this->ldapConnection, $usernameDN, $passwordBind);
Expand Down

0 comments on commit 814f109

Please sign in to comment.