function ldap_api_edit_server_form_validate in Lightweight Directory Access Protocol (LDAP) 6
Validate hook for the LDAP server form.
File
- ./
ldap_server.admin.inc, line 230
Code
function ldap_api_edit_server_form_validate($form, &$form_state) {
$values = $form_state['values'];
// Check for duplicated LDAP Server Names
if (!isset($values['sid'])) {
if (db_fetch_object(db_query("SELECT name FROM {ldap_servers} WHERE name = '%s'", $values['name']))) {
form_set_error('name', t('An LDAP config with the name %name already exists.', array(
'%name' => $values['name'],
)));
}
}
elseif (db_fetch_object(db_query("SELECT name FROM {ldap_servers} WHERE name = '%s' and sid != '%d'", $values['name'], $values['sid']))) {
form_set_error('name', t('An LDAP config with the name %name already exists.', array(
'%name' => $values['name'],
)));
}
// Ensure that the port number is actually a number.
if (!is_numeric($values['port'])) {
form_set_error('port', t('The TCP/IP port must be an integer.'));
}
}