Force logout when enrolment fails

Force logout when enrolment fails

by Jeremy Crabtree -
Number of replies: 1
I am working on an authentication/enrolment plugin pair to connect Moodle to my Uni's (extremely modified) LDAP directory. (The included LDAP plugins can't handle out LDAP setup).

I have my plugins mostly complete (authentication is fully complete, actually), but I am running into an issue with the enrolment plugin.

In my plugin I use a table of course mappings (stored in our MySQL DB) to map a user's courses from our LDAP server to the courses in our MOODLE server. If this mapping fails, I then check to see if the user account has been manually assigned to any roles on the Moodle server (to cover the case of someone auditing a course, which wouldn't show in the LDAP directory).

My problem arises after this last step. If the user doesn't map via LDAP to any of our courses AND they haven't been manually enroled, then they shouldn't be allowed on our server. The problem is that Moodle creates an account in the DB for anyone who authenticates and, when my enrolment plugin doesn't enrol them into any courses, directs them to the "edit" profile page, then onward to their (empty) MyMoodle page. I want to be able to force a logout if enrolment fails. I have tried various redirects from within my enrolment plugin, but I they do not work. Is it even possible to do this?

I would prefer not to have to actually alter Moodle, I would like my plugin to be usable by other departments at my University if they want to use it. (Also, if I'm allowed by my dept., I'd be glad to share it with the community)

Thanks for any pointers.
Average of ratings: -
In reply to Jeremy Crabtree

Re: Force logout when enrolment fails

by Jeremy Crabtree -
Okay, nevermind this. We decided it would be far friendlier to simply enrol non-student/teacher visitors into a generalized "Welcome to our Moodle Server" course with a feedback form to contact us if they are there rather than their intended courses.