code: def _search_for_user_dn(self):
          
          search = self.settings.USER_SEARCH
          if search is None:
              raise ImproperlyConfigured(
                  "AUTH_LDAP_USER_SEARCH must be an LDAPSearch instance."
              )
  
          results = search.execute(self.connection, {"user": self._username})
          if results is not None and len(results) == 1:
              (user_dn, self._user_attrs) = next(iter(results))
          else:
              user_dn = None
  
          return user_dn
docs: Searches the directory for a user matching AUTH_LDAP_USER_SEARCH.
          Populates self._user_dn and self._user_attrs.