public function LdapUserManager::createLdapEntry in Lightweight Directory Access Protocol (LDAP) 8.4
Create LDAP User entry.
Adds AD-specific password handling.
Parameters
\Symfony\Component\Ldap\Entry $entry: LDAP Entry.
Return value
bool Result of action.
Overrides LdapBaseManager::createLdapEntry
File
- ldap_servers/
src/ LdapUserManager.php, line 76
Class
- LdapUserManager
- LDAP User Manager.
Namespace
Drupal\ldap_serversCode
public function createLdapEntry(Entry $entry) : bool {
if (!$this
->checkAvailability()) {
return FALSE;
}
// Can be mixed case on direction-to-LDAP.
if ($entry
->hasAttribute('unicodePwd', FALSE) && $this->server
->get('type') === 'ad') {
$converted = $this
->convertPasswordForActiveDirectoryUnicodePwd($entry
->getAttribute('unicodePwd', FALSE)[0]);
$entry
->setAttribute('unicodePwd', [
$converted,
]);
}
try {
$this->ldap
->getEntryManager()
->add($entry);
} catch (LdapException $e) {
$this->logger
->error("LDAP server %id exception: %ldap_error", [
'%id' => $this->server
->id(),
'%ldap_error' => $e
->getMessage(),
]);
return FALSE;
}
return TRUE;
}