public function Server::bind in Lightweight Directory Access Protocol (LDAP) 8.3
Bind (authenticate) against an active LDAP database.
Return value
int Result of bind in form of LDAP_SUCCESS or relevant error.
1 call to Server::bind()
- Server::connectAndBindIfNotAlready in ldap_servers/
src/ Entity/ Server.php - Checks if connected and connects and binds otherwise.
File
- ldap_servers/
src/ Entity/ Server.php, line 219
Class
- Server
- Defines the Server entity.
Namespace
Drupal\ldap_servers\EntityCode
public function bind() {
// Ensure that we have an active server connection.
if (!$this->connection) {
$this->logger
->error("LDAP bind failure. Not connected to LDAP server.");
return self::LDAP_CONNECT_ERROR;
}
// Explicitly check for valid binding due to some upgrade issues.
$validMethods = [
'service_account',
'user',
'anon',
'anon_user',
];
if (!in_array($this
->get('bind_method'), $validMethods)) {
$this->logger
->error("Bind method missing.");
return self::LDAP_CONNECT_ERROR;
}
if ($this
->get('bind_method') == 'anon') {
$anon_bind = TRUE;
}
elseif ($this
->get('bind_method') == 'anon_user') {
if (CredentialsStorage::validateCredentials()) {
$anon_bind = FALSE;
}
else {
$anon_bind = TRUE;
}
}
else {
$anon_bind = FALSE;
}
if ($anon_bind) {
$response = $this
->anonymousBind();
}
else {
$response = $this
->nonAnonymousBind();
}
return $response;
}