function ldap_badattr in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.functions.inc \ldap_badattr()
- 7 ldap_servers/ldap_servers.functions.inc \ldap_badattr()
This attempts to find bad dns, but should only be used as warningswe as the ldap spec allows for any old character to be escaped and ldap implementations may not follow the spec.
Http://www.ietf.org/rfc/rfc2253.txt.
File
- ldap_servers/
ldap_servers.functions.inc, line 103 - Collection of functions that don't belong in server object.
Code
function ldap_badattr($attr, $attr_name) {
$result = [];
$valid_attr_name = '[_a-zA-Z\\d\\s]';
$regex = '/^(' . $valid_attr_name . '){1,}$/';
$match = preg_match($regex, $attr) ? TRUE : FALSE;
$result['boolean'] = $match;
if (!$match) {
$tokens = [
'%attr' => htmlspecialchars($attr),
'%attr_name' => $attr_name,
];
$result['text'] = t('Possible invalid format for %attr_name:', $tokens) . ' <code><em>' . $tokens['%attr'] . '</em></code><br/>' . t('The format may be correct for your ldap, but please double check.', $tokens);
}
return $result;
}