Closed goose2000 closed 8 years ago
Following the debug info above, we get as far as "Live session detected". then checks against uid for anonymous user, and that's where I got stopped, so never pick up the uid.
Well, apply more logic to it and I must assume:
debugging("
Live session detected the user returned is\r\n".print_r($ret,true)."
", DEBUG_DEVELOPER);
$uid = $ret->user->uid;
if ($uid < 1) { //No anon
return;
}
// The Drupal session is valid; now check if Moodle is logged in...
if (isloggedin() && !isguestuser()) {
return;
}
$drupaluser = $apiObj->Index("user/{$uid}");
debugging("<pre>The full user data about this user is:\r\n".print_r($drupaluser,true)."</pre>",DEBUG_DEVELOPER);
//create/update looks up the user and writes updated information to the DB
$this->create_update_user($drupaluser);
Going to add some more debug statements ...
Problem was with Shibboleth module unnecessarily deleting the cookie session and re-generating it. And so Moodle SSO lost the cookie, or more accurately, working with old cookie session.
Well, I'm going to document this anyway, maybe esoteric problem/bug but might help someone else. My latest situation / configuration is this:
Have a working installation of mood-drupalservices. Works great with regular authenticated Drupal users, got profile fields populating and updating - great.
Then I tried to get tricky. I need to let university people login to Drupal using Shibboleth. That works too, I can get attributes from the Idp and create local Drupal users, so they are 'authenticated' users.
Trouble occurs when this type of user tries to SSO into Moodle, it appears to find the cookie session but then it can't load the correct uid , and then defaults to anonymous, and it all stops, some debug dump of said user:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
attempting to reach service url: http://ssw.unc.edu/sswevents/index.php?q=/moodlesso/user/token
attempting to reach service url: http://ssw.unc.edu/sswevents/index.php?q=/moodlesso/system/connect
Live session detected the user returned is stdClass Object ( [sessid] => xgKNPJ4drkyPJUuJmWCZusTugxjNipuZ3NaJop3sEhE [session_name] => SESS321f1fdf5d46e0df333ef0d3e4d768aa [user] => stdClass Object ( [uid] => 0 [hostname] => 152.19.139.73 [roles] => stdClass Object ( [1] => anonymous user )
)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Now remember, this all works with a regular Drupal user, so close!