private function Server::nonAnonymousBind in Lightweight Directory Access Protocol (LDAP) 8.3
Bind to server with credentials.
This uses either service account credentials or stored credentials if it has been toggled through CredentialsStorage::testCredentials(true).
Return value
int Returns the binding response code from LDAP.
1 call to Server::nonAnonymousBind()
- Server::bind in ldap_servers/
src/ Entity/ Server.php - Bind (authenticate) against an active LDAP database.
File
- ldap_servers/
src/ Entity/ Server.php, line 286
Class
- Server
- Defines the Server entity.
Namespace
Drupal\ldap_servers\EntityCode
private function nonAnonymousBind() {
// Default credentials form service account.
$userDn = $this
->get('binddn');
$password = $this
->get('bindpw');
// Runtime credentials for user binding and password checking.
if (CredentialsStorage::validateCredentials()) {
$userDn = CredentialsStorage::getUserDn();
$password = CredentialsStorage::getPassword();
}
if (mb_strlen($password) == 0 || mb_strlen($userDn) == 0) {
$this->logger
->notice("LDAP bind failure due to missing credentials for user userdn=%userdn, pass=%pass.", [
'%userdn' => $userDn,
'%pass' => $password,
]);
$response = self::LDAP_LOCAL_ERROR;
}
if (@(!ldap_bind($this->connection, $userDn, $password))) {
$this->detailLog
->log("LDAP bind failure for user %user. Error %errno: %error", [
'%user' => $userDn,
'%errno' => ldap_errno($this->connection),
'%error' => ldap_error($this->connection),
]);
$response = ldap_errno($this->connection);
}
else {
$response = self::LDAP_SUCCESS;
}
return $response;
}