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

October 26, 2017 - 17:13

Moodle is a Free and Open-Source Software (FOSS) learning management system written in PHP. Drupal is also an Open-Source CMS. Our requirement is to integrate Moodle and Drupal with a single login system. For that I have followed 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.

Get Drupal updates straight to your inbox

To prevent automated spam submissions leave this field empty.

Post your comments / questions