[SOLVED] How to Integrate Moodle and Drupal with Single Login System?

| | 2 min read

Moodle is a Free and Open-Source Software (FOSS) learning management system written in PHP. Drupal is also an Open-Source CMS. We require to integrate Moodle and Drupal with a single login system. For that, I have followed the steps mentioned below.

Changes to be done in the Drupal site:

  1. Install the following modules in the Drupal site.
  2. In Drupal there should be a user with role 'service-authentication' which is required by the Moodle site Drupal services configuration.
  3. Create user fields like firstname, lastname,city, country etc because Moodle requires these values. Please note the input for the Country field should be 2 characters.

Changes to be Done in the Moodle Side:

After installing Moodle in the same server,

  1. Download the plugin 'moodle-drupalservices-master'(Moodle plugin to connect to Drupal services) and rename it to 'drupalservices' and put the folder in auth directory of moodle. ie, moodle -> auth -> drupalservices.
    sudo wget https://github.com/cannod/moodle-drupalservices/archive/master.zip
    sudo mkdir drupalservices
    sudo unzip master.zip -d drupalservices/
    sudo mv moodle-drupalservices-master/* .
    sudo mv drupalservices/ moodle/auth/
    This plugin checks if there is a valid Drupal session cookie and then connects to Drupal services and retrieves Drupal user info.
  2. Login to Moodle site with admin credentials and then go to Plugins -> Authentication -> Manage Authentication -> Drupalservices. Configure Drupalservices by specifying the Drupal site URL and Drupal fields for user data and enable the service.
  3. Run cron from Moodle side. /usr/bin/php path/to/moodle/admin/cli/cron.php.

For Testing Single Sign on

  1. Login to Drupal site.
  2. Access the Moodle site. You will be forced to enter the basic information for first time users.
  3. Logout from the Moodle site. You will be automatically logged out from the Drupal site also.