Debugging for LDAP authentication for Moodle

I have configured the LDAP authentication and added /auth/ldap/cli/sync_users.php to the crontab as described in the official manual:

But with no luck the LDAP thingy seemed to be failing to work properly. I believe the cron job has been set up properly, so I suppose I may have made some mistakes, or not providing enough information in the configuration for the LDAP authentication plugin.

As the cron script must be called from the command line, and I only have access to the FTP and MySQL database on the server, I have no idea how to execute the file to check if there are any errors (for debugging purpose).

So, I would like to know the proper way(s) to debug the LDAP authentication. Please let me know if I am not making it clear enough. I could provide more details if needed. Thank you.

        • UPDATES * * * *

I have tried to run the /admin/cron.php on a browser, and I have found the following lines in the output.

Running auth crons if required...
... started 10:24:18. Current memory use 27.9MB.

Does it have anything to do with the LDAP authentication? And what does it imply here?


Have you got something like this in your cron?

*/15 * * * * /usr/bin/php  /path/to/moodle/auth/ldap/cli/sync_users.php >/dev/null

You could probably redirect the output to a log file to see whats going on.

*/15 * * * * /usr/bin/php  /path/to/moodle/auth/ldap/cli/sync_users.php > /path/to/home/ldaperrors.log 2>&1

Also try it with debugging - add these to the config.php - not on a production site though, otherwise your users might see lots of errors.

@error_reporting(E_ALL | E_STRICT);
@ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;

For those who stumble upon this via a search... In Moodle 3.0 and above, cron jobs can be viewed and run from Site Administration>Server>Scheduled Tasks.

Very useful to view output of the task (in this case the LDAP authentication).

Need Your Help

Alternative Control Structures

java c++ c objective-c

I've been wondering about alternative ways to write control structures like you can write your own language constructs in Forth.

Laravel: Unit testing with authentication

php api unit-testing laravel phpunit

I'm trying to put some tests in my Laravel app. First, I'm checking that the login is working fine :