function ldap_servers_convert_password_for_active_directory_unicodePwd in Lightweight Directory Access Protocol (LDAP) 7.2
Converts a password to the format that Active Directory supports (for the purpose of changing or setting). 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 ldap_servers_convert_password_for_active_directory_unicodePwd()
- LdapServer::createLdapEntry in ldap_servers/
LdapServer.class.php - Create ldap entry.
- LdapServer::modifyLdapEntry in ldap_servers/
LdapServer.class.php - Modify attributes of ldap entry.
File
- ldap_servers/
ldap_servers.functions.inc, line 61 - Collection of functions that don't belong in server object.
Code
function ldap_servers_convert_password_for_active_directory_unicodePwd($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"),
];
}
}