External database authentication


Location: Site administration > Plugins > Authentication > External database

This method uses an external database table to check whether a given username and password is valid. If the user does not currently exist in Moodle a new account will be created and their information copied from the external database.


Field mappings

This is done by mapping fields at the bottom of the database authentication page. Each data field in the user profile has a text field next to it. Enter the name of the column in the external database that maps to the profile data field.

Update Local - Specifies that the external data will be entered into the local field in question

Update External - Specifies just the opposite, meaning changes in the local Moodle field in question will update the corresponding field in the external database

Lock Value - Only determines whether the local user can make a change in the Moodle field and does not affect the two settings above.

Automatic Synchronisation

The above method adds new users only when they log in. If you want user accounts to be created in Moodle independent of actual logins, the db authentication plugin offers a script we can run regularly via 'cron'. A typical cron entry will be as follows...

0 * * * *    /usr/bin/php /path/to/moodle/auth/db/cli/sync_users.php >dev/null

This runs every hour (adjust as required). It reads the entire table updating and creating local Moodle users.

If you have custom profile fields on your site, these can be synced with External database authentication (syncing custom profile fields from the external database to Moodle does not currently work, see [1]).

Additional Notes

It is now possible to use Salted Crypt passwords for the password format with external database authentication from the Password format setting:

See also