Unable to reset user password on non-ldap accounts

Created on 30 November 2021, almost 3 years ago
Updated 3 May 2024, 7 months ago

Problem/Motivation

Non-admin, non-ldap users are unable to reset their passwords, or edit their user account, when LDAP Authentication with mixed-mode and a default server is enabled.

The following error is given:

TypeError: Drupal\ldap_servers\LdapBaseManager::queryAllBaseDnLdapForUsername(): Argument #1 ($drupal_username) must be of type string, bool given, called in C:\inetpub\wwwroot\web\modules\contrib\ldap\ldap_authentication\src\Controller\LoginValidatorLoginForm.php on line 125 in Drupal\ldap_servers\LdapBaseManager->queryAllBaseDnLdapForUsername() (line 390 of modules\contrib\ldap\ldap_servers\src\LdapBaseManager.php).
Drupal\ldap_authentication\Controller\LoginValidatorLoginForm->testCredentials() (Line: 216)
Drupal\ldap_authentication\Controller\LoginValidatorLoginForm->validateCredentialsLoggedIn() (Line: 80)
Drupal\ldap_user\Plugin\Validation\Constraint\LdapProtectedUserFieldConstraintValidator->validate() (Line: 202)

Steps to reproduce

  1. With LDAP Authentication mixed-mode, and a default server enabled, login as a non-admin, non-ldap user.
  2. Make an update to the user entity
  3. Save the user

Proposed resolution

Check if $this->authName has a value before running $this->ldapUserManager->queryAllBaseDnLdapForUsername($this->authName) in ldap/ldap_authentication/src/Controller/LoginValidatorLoginForm.php

      // Check if user exists in LDAP.
      $this->ldapUserManager->setServer($this->serverDrupalUser);
      if($this->authName) {
        $entry = $this->ldapUserManager->queryAllBaseDnLdapForUsername($this->authName);
        if ($entry) {
          $this->ldapUserManager->sanitizeUserDataResponse($entry, $this->authName);
        }
      }

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States vetchneons

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024