CMS integrations: Moodle Block for Drupal 6.x now with real SSO

CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
Number of replies: 42
I have extended the Drupal <-> Moodle integration block that I've presented in the tread "Moodle Block for Drupal 6.x". It now automatically supports true Single-Sign-On from Drupal to Moodle, if LDAP server authentication is used and configured accordingly. In this thread, I am showing how that looks.

Drupal's "Moodle" block first offers a link "Sign-on to Moodle" to users logged into Drupal but haven't switched to Moodle so far.

Attachment 01.Sign-on_to_Moodle.jpg
Average of ratings: -
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
As shown in the mouse-over description of that link, clicking on it opens a new window, into which the user will be signed on automatically to Moodle. Before that window has fully loaded Moodle as the logged in user, a progress bar "Signing on to Moodle" is visible shortly.

Attachment 02.Signing_on_to_Moodle.jpg
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
Once the progress bar has disappeared, you are logged into Moodle, being in Moodle's start page.

Attachment 03.Moodle_s_start_page.jpg
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
When you switch back to the original window, the link in Drupal's Moodle Block has automagically changed to "Switch to Moodle". As shown in the mouse-over description of that link, clicking on it switches to the Moodle window and loads it's start page.

Attachment 04.Switch_to_Moodle.jpg
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
As requested on the original "Moodle Block for Drupal 6.x" thread, I am attaching the first public version (v0.3) of this Block's code here.
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Panda Shark -
Can tell it works smile

I found a bug.. when i login in drupal then i can login to moodle, the if i logout in moodle, i still login in drupal, and the link still say switch to moodle... when i click, the new moodle window open, but go to the moodle login form.

Somethings would be great.. when i logout in one place should be logged out in both sites (drupal and moodle)
Don't pass the password from ldap in plain text ... maybe a new authentication method in moodle...

For the job until now congrats rob smile
In reply to Panda Shark

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
You are right, my solution works to Single-Sign-On, but currently not to Single-Log-Out. That's sufficient to me for now. Moodle currently does not destroy any of its cookies on logout - that's why my Drupal block thinks the user is still logged into Moodle. So we may need to fix Moodle's logout process. I will look into it closer when I find time.

Glad it's working for you, too .-)
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Panda Shark -
Hy robert,

Do you know how to hook the logout action un drupal? I think one solution can be there.. for instance when i call the drupal logout function we can send an ajax request to the moodle/logout.php and then go on with the drupal logout.. What do you think?

I'm searching how to do that in the template.php file of the theme... if you can help with some info that you know it would be great smile
In reply to Panda Shark

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Panda Shark -
I have managed to hook the logout in drupal with jquery. I can't know signout from osticket for example.

In moodle i must find the current sessionkey or i will asked to confirm if i really want logout... next task... find that moodle sessionkey in the drupal
In reply to Panda Shark

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
I did not yet dig into the logout thing. However, I have updated the Block to version 0.4.

v0.4 (2009-02-22)

+ Progress bar is now dynamically and in "Drupal style"

+ The block can optionally also display a link to Drupal's Forums. Useful to
only offer the "Forums" link to authenticated users.

In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
Here is how the v0.4 block looks with the "Forums" link enabled:

Attachment 01.Community_Block.jpg
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
And here is how the new dynamic Drupal-style progress bar looks like:

Attachment 02.Signing-on_to_Moodle_Progressbar.png
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Camilo Rivera -
My moodle site is in a Subdomain under de same domain that drupal is:

Drupal is in: http://mydomain.com
and Moodle is in: http://subdomain.mydomain.com

does your code still applies to this? or only to directories within the same domain..??

if so, how could I config the URL at the file "Moodle Block.php" since it is asking for a slash at the begining and at the end

@Moodle Block.php

# URL to Moodle's home directory:
# Must begin and end with a slash (/)!
$moodle_url = 'http://subdomain.mydomain.com/';


Thank you!
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Syamsul Anwar -
Greetings. I would like to enquire whether a similar method also exists for getting my students to login to the Drupal site from Moodle (i.e. login to Moodle, click a link and be logged in to Drupal).

Thank you!
In reply to Syamsul Anwar

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Margo Williams -

I have this same exact need! This module would be TERRIFIC if it went from Moodle to Drupal instead of the other way around.

In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Prashanth Mahankali -

Hi Robert

I have done the same as you told but for me it is not working.When i click on the link in Drupal,the moodle site is asking to login,

Please Help me i have spen so many hours on this.

I am using moodle 1.9 version and please find my LDAP Settings for Moodle

Please Help me in this.

Thanks in Advance

In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Quinn Shanahan -
does your sso implementation mean drupal and moodle share the same user database?
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Glenn Murdoch -
Hi

Instead of having a new browser window, can I incorporate Moodle into my Drupal node?

I think I could do this with an iframe, but want to avoid this.

Will Panels do this in Drupal?

Thanks

Glenn
In reply to Glenn Murdoch

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
Attached is version 0.5 of my block.
v0.5 (2009-02-25)

+ The "drupal2moodle.php" page ensures to always fetch fresh content from the
 server

+ If SSO capability has been detected, the Moodle block will always offer the
 "Sign-on to Moodle" link to logged-in Drupal users when a page is loaded. This
 ensures to always load the Moodle window as logged-in Moodle user, regardless
 of Moodle's actual login status or present cookies.

+ Text addedd to the progress bar

+ ReadMe file ("ReadMe.txt") enhanced.

@Quinn: No, Drupal and Moodle do not use the same users SQL table. The user data are stored on the LDAP server and automatically synchronized to and from both Drupal and Moodle.

@Glenn: I also dislike iframes and will not write or use code that makes use of them. At the moment, both Drupal and Moodle operate in their own windows.
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Glenn Murdoch -
Robert

Thanks. The project I am working on currently uses Drupal 5.x. I assume that it's safe to assume that your module doesn't work with Drupal 5?

If not, are you planning a port back to 5.x?

If not I'm stuck with iframes I think? A friend suggested I look at sessions, I think this is what your module is using?

I'm pretty new to Drupal, very new to Moodle, and have basic knowledge of PHP coding. Are you able to point me at something that I can use to avoid the iframes?

Thanks for any help.

Glenn
In reply to Glenn Murdoch

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
Glenn, you are right, I haven't yet thought about Drupal 5. My solution is currently alpha code (thus the 0.x version numbering) and has only been tested with Drupal 6. Anyway, it relies on Drupal's LDAP integration module 6.x-1.x-dev. Since there is no 5.x dev version of that module, it seems that support for Drupal 5 has been dropped.

Cheers
rob.
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Robert Allerstorfer -
Attached is version 0.6 of my "Switch to Moodle" block for Drupal 6.x.
v6.x-0.6 (2009-03-11)

+ Since Miglius has committed the patch to fix http://drupal.org/node/380956, it
 no longer must be applied to the "LDAP integration" module. The ReadMe has
 been updated to reflect the new required version of ldap_integration.

+ Forums stuff that was introduced in v6.x-0.4 has been removed. The Forums link
 should better go to the Navigation menu block which may be configured to only
 be shown to the "authenticated user" role. 
Average of ratings: Useful (2)
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Phil Weaver -
Hi Robert,

I've followed your instructions to install but it doesn't seem to be working. I do not see the status bar and it brings me to the login page as a non logged in user.

Instructions seemed pretty simple so not sure what I could have missed. Any ideas?

Thank You

Phil


In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Chris Collman -
Picture of Documentation writers
Hi Robert,
Thank you and the others who are contributing to this thread for their work! My site administrator asked me to do some research about using Drupal and Moodle. I am a real newbie in the area of SSO and not a developer!

Any chance you could add the current version up in the Modules and Plugin database? I will try to update the MoodleDocs Integrations page as part of my contribution as I try to blindly test things by rote. I do have editing rights in M&P but limit myself to cross linking and minor verbage tweaks.

FYI: yesterday I created an 1.7.1 XAMPP site on my desktop for testing with Drupal 6 and Moodle 1.9.5 (May). Never used Drupal before, so there is another learning curve. So I think I am sort of ready to try some focused projects like SSO.

Best to all Chris

In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Luana Sarafino -

Hi Robert,

I've used all you instructions with switch_to_moodle-6.x-0.6 but Drupal doesn't pass the password to Moodle. Which may be the problem?

In ReadMe.txt there is this sentence: 'sharing the same user login data (via LDAP server recommended)'.What should I do?Do I only follow the instruction below this sentence?

Thank you Robert 

In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by David O'Leyar -

I have successfully implemented your Drupal-Moodle single sign-on using LDAP and now wonder if your solution will work if and when I switch to Moodle 2.0 when it becomes available?  I do think that the code for the Drupal side probably won't change but will there be any changes on the Moodle side?

As I haven't seen Moodle 2.0 I am somewhat worried that simply updating to the new version might break what I already have working.

 

In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Glenn Murdoch -
Robert

I've not played with Drupal's LDAP module at all. Does this mean my server needs to be running an LDAP server?

Also, this is currently an SSO process. I want to implement having users pay for a course in Drupal, and they are automatically enrolled in the appropriate Moodle course.

Any ideas?

Thanks

Glenn
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Glenn Murdoch -
Rob

The LDAP Integration module has both a 4.7 and 5.x version so far as I can see. I'm looking at http://drupal.org/project/ldap_integration, is this right?

Thanks

Glenn
In reply to Glenn Murdoch

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Andre Angelantoni -
Glenn,
I see a version for 6.x:
6.x-1.0-alpha2

I'm about to start installing it now.
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Martijn Haan -
Very much interested in Drupal/moodle integration. There is a drupal module for this. http://www.drupal.org/project/moodle . Is this attachment shown here the latest (6 version) an extention of this integration?
Greetings, Martijn
In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Marco Rojas -
Hi,

Looks like there is a newer module for the integration as posted, the package is much newer than the one attached in this forum.

The problem I am having with the module from drupal (here), when I put that module in /drupal/sites/all/modules and go to enable it on the GUI I get to a blank page and nothing happens.

I am using drupal 6.16, any ideas in why the module won't install?

Thank you.
In reply to Marco Rojas

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Frank Ralf -
Hi Marco,

That seems more like a Drupal related problem. See Blank pages and missing content for a solution.

The first thing I would try is uploading the module again to make sure all files are there and intact.

Have you installed the Moodle Quick API plugin for Moodle?

"Note 2: The integration features included in this module require the Moodle Quick API plugin and Moodle version 1.9.x to function. Drupal policy does not allow it to be stored in Drupal.org's CVS."

hth
Frank
In reply to Frank Ralf

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Marco Rojas -
Thank you for your response Frank...I was able to get passed the blank screen by hitting F5 and now the module is installed.

I installed the Quick API on Moodle which is 1.9.x. I entered the Moodle address in the module configuration as https://moogle.example.com/ but when I click on the Moodle link I am not getting authenticated. It takes me to the login page of moodle.

Drupal is configured to authenticate to an the same OU Moodle is in active directory, I can login to both system with my ldap account.

I added my computer's IP to the Quick API report in Moodle but It doesn't make a difference.

Could it be a cookie issue?

Thanks

Marco
In reply to Marco Rojas

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Big Fan -
Hello Marco!

I have set up this integration with a few modifications.

The script is being loaded in the background (ajax) and is executed the first time the user lands on the Drupal site. All links from Drupal to my Moodle course content are direct since the user is already logged in.

It works perfect when both Drupal and Moodle are inside the same path i.e. mydrupal.com and mydrupal.com/moodle.

The integration has since stopped working after switching to a subdomain setup i.e. my.drupal.com and moodle.drupal.com.

Has anyone got this to work across sub domains?


--
At some point I will be contributing my Moodle Integration effort which includes an exposed view of the drupal gradebook with custom filters, email notifications, and the minor jquery changes for this auto login block.
In reply to Big Fan

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Marco Rojas -
Hi Big Fan,

My testing server has both Moodle and Drupal in /var/www/. I don't think I have tried just using server's IP since I always install using the FQDN because the sites need to on the web. I also have them setup as virtual sites so that I don't have to do site.com/moddle, site.com/drupal and so on....I rather do site-moodle.com and site-drupal.com.

What modifications have you done to the plugin...can you post them?
In reply to Marco Rojas

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Big Fan -
Hey Marco

I have resolved the subdomain issue, inside of moodle you can specify a domain so that any cookie generated from drupal's subdomain can be referenced.

The modifications use the login script to generate a cookie on the fly using an iframe and AJAX requests.
In reply to Big Fan

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Marco Rojas -
Interesting....I need to take a look at it. I had a feeling it was a cookie issue. Thanks for sharing.

I nice more specific HOWTO would be nice. If I get it working I will create one.
In reply to Marco Rojas

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Attila Paksi -
Hi Moodlers,

What if I dont have an LDAP server?
I installed the open-id plugin for moodle, and the drupal 6 compatible openid provider module.
Is it possbile to use the "Moodle Block for Drupal 6.x" addon without LDAP server? Only with an SSO connection by the help of openid? (the openid provider module help to the moodle to see the user table of the drupal as openid server).
But I have no idea how to use this SSO-openid combo as a "seamless" change between drupal and moodle interface.
Any idea, suggestion?

Thank you
In reply to Marco Rojas

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by David O'Leyar -

I'm not quite sure if I understand the "cookie issue" you cite,  if that is the fact that the initial cookie that is set is not released when you exit Moodle then I might have a solution.  At my current location I don't have access to my code but I was able to kill the cookie by making a modification of the code that runs when the loggout is made from Moodle.  When I get the chance I will provide details in a later post.

 

In reply to Frank Ralf

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Amar Shukla -

I set up both moodle and drupal setup ...but i m not able to configure ldap server in moodle...how should i comfigure ldap on drupal & what wud be the user type while configuring ldap in moodle...& when i m trying to login on drupal it is giving me error

  • warning: ldap_connect() [function.ldap-connect]: Could not create session handle: Bad parameter to an ldap routine in /var/www/drupal/sites/all/modules/ldap_integration/includes/LDAPInterface.inc on line 132.
  • warning: ldap_errno(): supplied argument is not a valid ldap link resource in /var/www/drupal/sites/all/modules/ldap_integration/includes/LDAPInterface.inc on line 167.
  • warning: ldap_error(): supplied argument is not a valid ldap link resource in /var/www/drupal/sites/all/modules/ldap_integration/includes/LDAPInterface.inc on line 167.

& how can i do automatic login from drupal to moodle..pls assist me on this..

In reply to Robert Allerstorfer

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by pranay nath -

hi,

do you think other modules of moodle will work in this setup of integration with drupal

DRUPAL(Moodle(Wiziq)))

In reply to pranay nath

Re: CMS integrations: Moodle Block for Drupal 6.x now with real SSO

by Frank Ralf -
This is a rather old and long thread. Better start a new one for your specific question.
You also might have a look at Integration FAQ for some pointers.

hth
Frank