You are here

public function ServerTestForm::testUserMapping in Lightweight Directory Access Protocol (LDAP) 8.3

Same name and namespace in other branches
  1. 8.4 ldap_servers/src/Form/ServerTestForm.php \Drupal\ldap_servers\Form\ServerTestForm::testUserMapping()

Test the user mappings.

Parameters

string $drupal_username: The Drupal username.

Return value

array Errors and the user.

2 calls to ServerTestForm::testUserMapping()
ServerTestForm::submitForm in ldap_servers/src/Form/ServerTestForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
ServerTestForm::testConnection in ldap_servers/src/Form/ServerTestForm.php
Test the connection.

File

ldap_servers/src/Form/ServerTestForm.php, line 455

Class

ServerTestForm
Use Drupal\Core\Form\FormBase;.

Namespace

Drupal\ldap_servers\Form

Code

public function testUserMapping($drupal_username) {
  $ldap_user = $this->ldapServer
    ->matchUsernameToExistingLdapEntry($drupal_username);
  if (!$ldap_user) {
    $this->resultsTables['basic'][] = [
      'class' => 'color-error',
      'data' => [
        $this
          ->t('Failed to find test user %username by searching on %user_attr = %username.', [
          '%username' => $drupal_username,
          '%user_attr' => $this->ldapServer
            ->get('user_attr'),
        ]),
      ],
    ];
    $this->exception = TRUE;
  }
  else {
    $this->resultsTables['basic'][] = [
      'class' => 'color-success',
      'data' => [
        $this
          ->t('Found test user %username by searching on  %user_attr = %username.', [
          '%username' => $drupal_username,
          '%user_attr' => $this->ldapServer
            ->get('user_attr'),
        ]),
      ],
    ];
  }
  return $ldap_user;
}