You are here

function ldaphelp_baddn in LDAP integration 6

1 call to ldaphelp_baddn()
ldaphelp_get_ldap_server in ldaphelp/ldaphelp_status.inc
Use the LDAP server info to create the status array for theme_status_report

File

ldaphelp/ldaphelp_status.inc, line 449
status file for ldaphelp module

Code

function ldaphelp_baddn($dn, $dn_name) {
  $result = array();
  $valid_attr_name = '[a-zA-Z\\d\\s]';
  $valid_attr_values = '[a-zA-Z\\d\\s]';
  $regex = '/^(' . $valid_attr_name . '*\\=' . $valid_attr_values . '*[,]{1})*(' . $valid_attr_name . '*\\=' . $valid_attr_values . '*){1}$/';

  // $target = "CN=Schema A1, CN2 =Configuration,DC=ad,DC=uiuc,DC=edu";
  // $target = "ou=education,dc=ad,dc=uiuc,dc=edu";
  $match = preg_match($regex, $dn) ? TRUE : FALSE;
  $result['boolean'] = $match;
  if (!$match) {
    $result['text'] = "Invalid format for:<br/> <code><strong>" . htmlspecialchars($dn) . "</strong><code><br/> One cause may be editing {$dn_name} with a wysiwyg editor which leaves html.";
  }
  return $result;
}