function ldap_servers_settings_submit in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.settings.inc \ldap_servers_settings_submit()
- 7 ldap_servers/ldap_servers.settings.inc \ldap_servers_settings_submit()
1 string reference to 'ldap_servers_settings_submit'
- ldap_servers_settings in ldap_servers/
ldap_servers.settings.inc
File
- ldap_servers/
ldap_servers.settings.inc, line 51 - Admin interface for general ldap api settings.
Code
function ldap_servers_settings_submit($form, &$form_state) {
if ($form_state['submitted']) {
$new_encyption = $form_state['values']['ldap_servers_encryption'];
$old_encyption = $form_state['values']['previous_encryption'];
// Use db instead of functions to avoid classes encryption and decryption.
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) {
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", [
':bindpw' => $rencrypted,
':sid' => $sid,
]);
}
}
}
}