Hi, I've been reading the API and VanDyk/Westgate's Pro Drupal Development book, and as far as I understand, there's no way to interrupt the Drupal login process with a module?

In other words, when a user attempts to login, is there a hook that gets called PRIOR to checking if the username and password match in the Drupal users database?

Or even better, is there a way to interrupt the login process and do an external database check on the username and password, and if there's a match, then proceed with the Drupal login process but with a different login and password?

I've been trying to do this for a few days without avail and it's driving me crazy :|

Comments

nevets’s picture

The simple answer is yes, Drupal has built in support for external authorization. Not having written such a module I do not know the detail. would look under http://drupal.org/project/Modules/category/74?page=1 to find a module that does something similar and proceed from there. One possible starting point would be the LDAP Integration module

aniskhan’s picture

I found modules that also have implemented what you suggest, external authorization, and then drupal registration. The difference is that I want to do an external authorization, and if it's correct, then login a pre-determined username into Drupal. In other words, there's only a single user in Drupal called "member", and if the external authorization is positive, then login that user as "member". I don't want it to register that user with the information it grabs from the external database. Does that make sense? :)

nevets’s picture

It may be possible to write a module that

a) Allows you to map these external users to a single user in Drupal by calling user_set_authmaps($account, $authmaps) something like

function yourmodule_somename($accountname) {
$uid = 10; // Drupal user id of common user
$account = user_load(array('uid' => $uid));
$authmaps = array('xxxx+_yourmodule' => $accountname);

user_set_authmaps($account, $authmaps);
}

You would need to implement a UI to allow new names to be entered and call yourmodule_somename() with the new name. You might also want a settings page to allow the fixed uid to be picked instead of hard coding the value.

The other part would be implementing hook_auth() in the module to do the external authorization.

There is the question why you want them to all map to the same username and not have their own logins. Doing so would make it hard to track down any trouble makers.

aniskhan’s picture

thanks, i'll look into it...

now i have another related problem, my hook_auth doesn't seem to get called :|
http://drupal.org/node/256018