Skip to content
Snippets Groups Projects
Commit f66099e9 authored by John Barclay's avatar John Barclay
Browse files

Check for empty bindpw before encrypting

parent 706ebd66
No related branches found
No related tags found
No related merge requests found
......@@ -234,7 +234,7 @@ class LdapServer {
}
if ($bindpw) {
$this->bindpw = ldap_servers_decrypt($bindpw);
$this->bindpw = ($bindpw == '') ? '' : ldap_servers_decrypt($bindpw);
}
$this->paginationEnabled = (boolean)(ldap_servers_php_supports_pagination() && $this->searchPagination);
......
......@@ -71,8 +71,13 @@ function ldap_servers_settings_submit($form, &$form_state) {
if ($new_encyption != $old_encyption) {
$servers = db_query("SELECT sid, bindpw FROM {ldap_servers} WHERE bindpw is not NULL AND bindpw <> ''")->fetchAllAssoc('sid');
foreach ($servers as $sid => $server) {
$decrypted_bind_pwd = ldap_servers_decrypt($server->bindpw, $old_encyption);
$rencrypted = ldap_servers_encrypt($decrypted_bind_pwd, $new_encyption);
if ($server->bindpw != '') {
$decrypted_bind_pwd = ldap_servers_decrypt($server->bindpw, $old_encyption);
$rencrypted = ldap_servers_encrypt($decrypted_bind_pwd, $new_encyption);
}
else {
$rencrypted = '';
}
db_query("UPDATE {ldap_servers} SET bindpw = :bindpw WHERE sid = :sid", array(':bindpw' => $rencrypted, ':sid' => $sid));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment