You are here

function ldap_servers_test_user_mapping in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.test_form.inc \ldap_servers_test_user_mapping()
  2. 7 ldap_servers/ldap_servers.test_form.inc \ldap_servers_test_user_mapping()
1 call to ldap_servers_test_user_mapping()
ldap_servers_test_form_submit in ldap_servers/ldap_servers.test_form.inc
Submit hook for the LDAP server form.

File

ldap_servers/ldap_servers.test_form.inc, line 418

Code

function ldap_servers_test_user_mapping($drupal_username, &$ldap_server, $ldap_context = NULL) {
  $ldap_user = $ldap_server
    ->userUserNameToExistingLdapEntry($drupal_username, $ldap_context);
  $errors = FALSE;
  if (!$ldap_user) {
    $results[] = t('Failed to find test user %username by searching on  %user_attr = %username.', [
      '%username' => $drupal_username,
      '%user_attr' => $ldap_server->user_attr,
    ]) . ' ' . t('Error Message:') . ' ' . $ldap_server
      ->errorMsg('ldap');
    $errors = TRUE;
  }
  else {
    $results[] = t('Found test user %username by searching on  %user_attr = %username.', [
      '%username' => $drupal_username,
      '%user_attr' => $ldap_server->user_attr,
    ]);
  }
  return [
    $errors,
    $results,
    $ldap_user,
  ];
}