Drupal / Moodle SSO

Events happening in the community are now at Drupal community events on www.drupal.org.
randa.elayan's picture

Hi All,

Has anyone ever worked on connecting Drupal 7 with Moodle 2.0, especially to perform the Single sign-on process?

I used Moodle-DrupalServices plugin in moodle, Services and Services Views in Drupal.

Set everything and created a REST server service.

The problem is, it is when I login in Drupal site, the Moodle site does not login, although when I logout from Moodle, it logout from Drupal.

Can anyone help?

Thanks
Randa

Comments

Cron maybe ?

rashad612's picture

This is just a guess. I think Moodle SSO should be configured by cron.
Cron should be configured to be called by PHP-CLI not by Drupal.
So that it will synchronize users between Drupal and Moodle based on periodic cron job. As you can read in the plugin file auth_drupal_sync_users.php

<?php
/** auth_drupal_sync_users.php
*
* This script is meant to be called from a system cronjob to sync moodle user
* accounts with Drupal.
*
* Sample cron entry:
* # 5 minutes past 4am
* 5 4 * * * $sudo -u www-data /usr/bin/php /var/www/moodle/auth/db/cli/sync_users.php
*
* Notes:
*   - it is required to use the web server account when executing PHP CLI scripts
*   - you need to change the "www-data" to match the apache user account
*   - use "su" if "sudo" not available
*   - If you have a large number of users, you may want to raise the memory limits
*     by passing -d memory_limit=256M
*   - For debugging & better logging, you are encouraged to use in the command line:
*     -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
*/

define('CLI_SCRIPT', true);

require_once(
dirname(dirname(dirname(<strong>FILE</strong>))).'/config.php');
require_once(
$CFG->dirroot.'/course/lib.php');

if (!
is_enabled_auth('drupal')) {
    echo
"Drupal SSO plugin not enabled!";
    die;
}

$drupalauth = get_auth_plugin('drupal');
$drupalauth->sync_users(true);
?>

Rashad S. Majali

Web Developer, Open Source Enthusiast.
Twitter: @rashad612

$drupalauth default as "drupalservices"

hoangbien's picture

Hello Rashad S. Majali,
I am working drupal 7 and moodle 2.x. I was install services, services views and drupalservices, so i configuration step by step. However, when i login on drupal site and go to moodle link. The moodle doesn't login. In the file auth_drupal_sync_users.php i see $drupalauth = get_auth_plugin('drupalservices'). Have i must to change it? How to single sign on between drupal and moodle? Help me please.
Thank you very much,

HOANG BIEN

Thanks

randa.elayan's picture

Yes, Thank you, I worked all the day trying to get the cron working for this,
and while debugging, I found that moodle executes some queries to fetch the username and id from drupal, and it succeeds, but when inserting / Updating the user info, it gives "Inserted user X id 46" comment but it does not really do the insert.

in the error_log file, I found this error:
Database transaction aborted automatically in /public_html/moodle/auth/db/cli/sync_users.php

seems there is a problem in the insert statements, but not sure where to get the exact error from.

Thank for helping :)

Randa

Support request

Jc Denton's picture

Hello,

I am trying to integrate drupal 7 with moodle 2.3.1 using drupal services. I am following the step by step read me file.
More specific:

Drupal
I created a service moodle and endpoint name mservice and enabled the resources required. I created role services and gave it unlimited index queries permission. Created a user (moodleuser) and included him in services role.

Moodle
drupal hostname: http://localohost/drupal
endpoint: /localhost/drupal/mservice
remoteuser: moodleuser
password: moodleuser_pass

ID Number: Locked

I get no errors and tested the endpoint URL and it works. Though when i log in to drupal, i' m going to Moodle and i'm not logged in there. What am i missing? Any advice would be really helpful.

Thank you in advance

solve error

tripathirahul55's picture

Hi

I am not sure may be your cron file not set are your moodle databe for user not update so go on your cmd prompt and run the syn script again .If its again not solve go on your Drupal and create new user and syn again may be its work for your create user!

Integration of Drupal7 with Moodle2.3

shahdarsh's picture

Hello,

Recently I have completed integration of Drupal 7 with Moodle 2.3, You login with Drupal, and automatically login in Moodle, and once you logout from moodle, it's also logout from Drupal.

https://github.com/cannod/moodle-drupalservices/wiki/Installation-Drupal...

https://github.com/cannod/moodle-drupalservices/wiki/Installation-Moodle...

Let me know if you need more help from my side.

Thanks,
Darshan(+91 9958834339)
Skype:shah.darshanv

I need one help.

tripathirahul55's picture

Hello shahdarsh

Its good sound you are also integrated moodle and drupal . I also integrated this with the help of two link which you give above but i have one point regarding that its integrated single side (Drupal to moodle ) or Both side . I am stock on the point for i want two side integration but its not working moodle to drupal . If this is possible so please share mi how i can do that .

Thanks in advance !

Hey, can you help me. I'm

sisko's picture

Hey, can you help me.

I'm following the same steps and when I log in to Drupal, I'm also logged into Moodle but there is a problem.

My users are presented with the Moodle user profile page where they have to provide firstname, lastname etc which is exactly what I'm trying to avoid.

I explained everything with images at http://stackoverflow.com/questions/31895966/moodle-drupal-sso

Can you help?

Yes, but need to look into

shahdarsh's picture

Yes, but need to look into once first on your website, so share more information about your site! You can add me on my skype id : shah.darshanv

service-authentication

qudsiyya-1's picture

I have followed the complete procedure to install moodle SSO for drupal. According to the wiki, you need to assign the Drupal user account that Moodle will use to the "service-authentication" role. I haven't got a role of 'service-authentication' in the list: do I need to create it, and if so what permissions does it need?

service-authentication

qudsiyya-1's picture

I have followed the complete procedure to install moodle SSO for drupal. According to the wiki, you need to assign the Drupal user account that Moodle will use to the "service-authentication" role. I haven't got a role of 'service-authentication' in the list: do I need to create it, and if so what permissions does it need?

Can't integration of D7 with Moodle2.3

hoangbien's picture

Hello everybody,
I tested integration of D7 with Moodle2.3 step by step with the help file on Github.com. However when i login on http://localhost/drupalservice so i gone to http://localhost/drupalservice/moodle. it doesn't login. Can you create help file with photos. I need one login, logout, register,
Help me please,
Thank you very much,

HOANG BIEN

Setup but can't login

wipeout_630's picture

I am having the same problems as stated above. Sync works correctly, no errors, users are populated in Moodle, cookies are configured correctly on both sites, but I cannot login to Moodle.

Drupal + Moodle

Candido Bertinatto's picture

Hello, is there anything new between integrating Drupal as Moodle?

Jordan

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: