Question2Answer LDAP admin login error 500

What type of hardware are you using: VPS bought online
What YunoHost version are you running: 12.0.17
What app is this about: Question2Answer

Describe your issue

I’ve just installed the Question2Answer app, so far so good. But when I try to login to the admin interface as set in the setup page, the app returns the error 500. When I check the nginx log I see an Call to undefined function ldap_connect() error thrown.

I checked if there is a reported issue and found one but without response:

Could you guys please recommend a remedy for this? Thank you!

Share relevant logs or error messages

2025/07/22 17:17:23 [error] 559844#559844: *4127 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function ldap_connect() in /var/www/question2answer/qa-plugin/qa-ldap-login/LDAPServer.php:10
Stack trace:
#0 /var/www/question2answer/qa-plugin/qa-ldap-login/qa-ldap-process.php(36): LDAPServer->connectWithServer()
#1 /var/www/question2answer/qa-plugin/qa-ldap-login/qa-ldap-process.php(58): ldap_process()
#2 /var/www/question2answer/qa-include/pages/login.php(62): require_once('...')
#3 /var/www/question2answer/qa-include/app/page.php(183): require('...')
#4 /var/www/question2answer/qa-include/qa-page.php(47): qa_get_request_content()
#5 /var/www/question2answer/qa-include/qa-index.php(189): require('...')
#6 /var/www/question2answer/index.php(27): require('...')
#7 {main}
  thrown in /var/www/question2answer/qa-plugin/qa-ldap-login/LDAPServer.php on line 10" while reading response header from upstream, client: 212.253.8.111, server: ****************, request: "POST /q2a/index.php/login?to=index.php%2Fadmin HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm-question2answer.sock:", host: "****************", referrer: "https://****************/q2a/index.php/login?to=index.php%2Fadmin"

Here I’ve come with the solution. With the help of ChatGPT (since I am not a web expert), I diagnosed the error message and find out that php8.0-ldap package was absent in the system. This absence was causing that LDAP login error message.

So, just install the package and restart the FPM:

apt update
apt install php8.0-ldap
systemctl restart php8.0-fpm

It seems that this installation step should have been added to the installation script by the maintainer.

I wish you knew @hermann-san bro :smiling_face_with_tear:

EDIT-1 - One more issue with non-LDAP users and a workaround

Well, there is one more issue after fixing the LDAP login. This time, a new non-LDAP user can register successfully, but cannot proceed login because the code in $ROOT/qa-plugin/qa-ldap-login/qa-ldap-process.php file does not allow normal login flow because of these lines:

} else {
        if(!qa_opt('ldap_login_allow_normal')) {
          // FIXME somehow print a message
          qa_redirect('login');
          exit();
        }
}

Removing that else block completely fixes the login flow and allow non-LDAP users to login. But this is a dirty way to solve this problem. A Yunohost level solution would be the best to overcome these 2 issues.

EDIT-2 - Just discovered a cleaner solution for non-LDAP login

After examining some of the qa-ldap-process.php source code, I noticed the following option that causes redirection to the login page: ldap_login_allow_normal.
This option determines whether a user without an LDAP account can log in. However, I couldn’t find this option on the admin page. So, while searching for the source of this option, I looked at the qa-include/app/options.php file and found that this option is taken from the database. I opened the database with AdminerEvo and started looking at the qa_options table. And finally, I found what I was looking for here: the ldap_login_allow_normal option was here. Since it did not have a default value, the application’s LDAP plugin did not allow normal login. I changed its value to 1, saved it, and tried normal login again. This time, without making any changes to the plugin’s source code, I was able to log in as a normal user.

Well I think this solution may be implemented in the Yunohost’s installer script of the package of this application.

Hope this workaround help to others that want to use this app in Yunohost

awesome work :slightly_smiling_face:
Thanks a lot for sharing it.
Hopefully the Yunohost people see this or maybe a Github issue need to be opened.

It looks like the repo hasn’t been updated since last year.

I will try to fix the problems I’ve found and create a PR, but I don’t promise anything :slightly_smiling_face:.

I will try to contribute to Yunohost for the first time. That’s why I need to read the documentation first.