You are here

function ldap_badattr in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_servers/ldap_servers.functions.inc \ldap_badattr()
  2. 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 85
collection of functions that don't belong in server object

Code

function ldap_badattr($attr, $attr_name) {
  $result = array();
  $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 = array(
      '%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;
}