**Problem:** 
Some AD users can't log in, they get the error:
`Authentification failed: password is incorrect or there is no user with such name`

Clickhouse version 22.3.2.1

**There is an error in Clickhouse logs:**
`<Error> Access(user directories): from: 10.11.12.13, user: AD_USERNAME: Authentification failed: Code: 532. DB::Exception: Size limit exceeded. (LDAP_ERROR)`

This error occurs for AD users who have many groups in the **memberOf** LDAP container.

**I checked the number of groups for 4 accounts:**

AD_USERNAME_1 - 107 groups - ERROR Authentification failed
AD_USERNAME_2 - 120 groups - ERROR Authentification failed
AD_USERNAME_3 - 54   groups - OK
AD_USERNAME_4 - 38   groups - OK

**I checked the search groups through the Ldapsearch program:**

Ldapsearch gave all 107 groups for the account without errors:
`ldapsearch -H "ldaps://hostname:636" -D 'CN=AD_USERNAME_1,OU=Users,DC=company,DC=corp.DC=net' -b 'DC=company,DC=corp.DC=net' '(&(objectClass=group)(member=CN=AD_USERNAME_1,OU=Groups,DC=company,DC=corp.DC=net))'`

**Probable cause of the error:** 
Clickhouse receives a list of groups which mapping from AD and cannot process a large string/array.
{
    std::scoped_lock lock(ldap_global_mutex);
    SearchResults result;
    int scope = 0;
    switch (search_params.scope)
    {
        case SearchParams::Scope::BASE:      scope = LDAP_SCOPE_BASE;     break;
        case SearchParams::Scope::ONE_LEVEL: scope = LDAP_SCOPE_ONELEVEL; break;
        case SearchParams::Scope::SUBTREE:   scope = LDAP_SCOPE_SUBTREE;  break;
        case SearchParams::Scope::CHILDREN:  scope = LDAP_SCOPE_CHILDREN; break;
    }
    const auto final_base_dn = replacePlaceholders(search_params.base_dn, {
        {"{user_name}", final_user_name},
        {"{bind_dn}", final_bind_dn},
        {"{user_dn}", final_user_dn}
    });
    const auto final_search_filter = replacePlaceholders(search_params.search_filter, {
        {"{user_name}", escapeForFilter(final_user_name)},
        {"{bind_dn}", escapeForFilter(final_bind_dn)},
        {"{user_dn}", escapeForFilter(final_user_dn)},
        {"{base_dn}", escapeForFilter(final_base_dn)}
    });
    char * attrs[] = { const_cast<char *>(search_params.attribute.c_str()), nullptr };
    ::timeval timeout = { params.search_timeout.count(), 0 };
    LDAPMessage* msgs = nullptr;
    SCOPE_EXIT({
        if (msgs)
        {
            ldap_msgfree(msgs);