public function Server::createLdapEntry in Lightweight Directory Access Protocol (LDAP) 8.3
Create LDAP entry.
Parameters
array $attributes: Should follow the structure of ldap_add functions. Entry array: http://us.php.net/manual/en/function.ldap-add.php $attributes["attribute1"] = "value"; $attributes["attribute2"][0] = "value1"; $attributes["attribute2"][1] = "value2";.
string $dn: Used as DN if $attributes['dn'] not present.
Return value
bool Result of action.
1 call to Server::createLdapEntry()
- Server::groupAddGroup in ldap_servers/
src/ Entity/ Server.php - Add a group entry.
File
- ldap_servers/
src/ Entity/ Server.php, line 432
Class
- Server
- Defines the Server entity.
Namespace
Drupal\ldap_servers\EntityCode
public function createLdapEntry(array $attributes, $dn = NULL) {
$this
->connectAndBindIfNotAlready();
if (isset($attributes['dn'])) {
$dn = $attributes['dn'];
unset($attributes['dn']);
}
elseif (!$dn) {
return FALSE;
}
if (!empty($attributes['unicodePwd']) && $this
->get('type') == 'ad') {
$attributes['unicodePwd'] = $this
->convertPasswordForActiveDirectoryunicodePwd($attributes['unicodePwd']);
}
$result = @ldap_add($this->connection, $dn, $attributes);
if (!$result) {
ldap_get_option($this->connection, self::LDAP_OPT_DIAGNOSTIC_MESSAGE_BYTE, $ldap_additional_info);
$this->logger
->error("LDAP Server ldap_add(%dn) Error Server ID = %id, LDAP Error %ldap_error. LDAP Additional info: %ldap_additional_info", [
'%dn' => $dn,
'%id' => $this
->id(),
'%ldap_error' => $this
->formattedError($this
->ldapErrorNumber()),
'%ldap_additional_info' => $ldap_additional_info,
]);
}
return $result;
}