public function Server::convertPasswordForActiveDirectoryunicodePwd in Lightweight Directory Access Protocol (LDAP) 8.3
Convert password to format required by Active Directory.
For the purpose of changing or setting the password. Note that AD needs the field to be called unicodePwd (as opposed to userPassword).
Parameters
string $password: The password that is being formatted for Active Directory unicodePwd field.
Return value
string $password surrounded with quotes and in UTF-16LE encoding
2 calls to Server::convertPasswordForActiveDirectoryunicodePwd()
- Server::createLdapEntry in ldap_servers/
src/ Entity/ Server.php - Create LDAP entry.
- Server::modifyLdapEntry in ldap_servers/
src/ Entity/ Server.php - Modify attributes of LDAP entry.
File
- ldap_servers/
src/ Entity/ Server.php, line 1783
Class
- Server
- Defines the Server entity.
Namespace
Drupal\ldap_servers\EntityCode
public function convertPasswordForActiveDirectoryunicodePwd($password) {
// This function can be called with $attributes['unicodePwd'] as an array.
if (!is_array($password)) {
return mb_convert_encoding("\"{$password}\"", "UTF-16LE");
}
else {
// Presumably there is no use case for there being more than one password
// in the $attributes array, hence it will be at index 0 and we return in
// kind.
return [
mb_convert_encoding("\"{$password[0]}\"", "UTF-16LE"),
];
}
}