Creating new users programmatically

quentinsf - August 16, 2009 - 13:39

Hello all,

I'd like to be able to create Drupal users automatically when accounts are created on another of our systems.

I can delve into writing some custom PHP but wondered if there was a Right Way to do this? A service, a module, a drush plugin... or even a way to get Drupal to authenticate with another system (which isn't an OpenID provider).

Many thanks!

Depends

yelvington - August 16, 2009 - 13:57

Depends on how you want it to behave.

Awhile back we created a module that authenticated against our proprietary registration system. It wasn't particularly hard. We used an existing module as a skeleton (http://drupal.org/project/httpauth).

Our proprietary system was already setting some encrypted session cookies, so if you hit Drupal with the cookies set, the module would check (via CURL) to make sure they were still valid. If so, you were "in," and if you didn't already have a corresponding Drupal account, one was silently created. We also intercepted the normal Drupal "create account" page, of course. Making all of this work took about a day.

If you want to ensure that there's always a Drupal account for each user of your legacy system, even if the user has never logged into Drupal, then you probably need to do some development on your legacy side so that it notifies Drupal of adds/drops. I don't think the Drupal side of that would be very hard to implement.

Thanks

quentinsf - August 16, 2009 - 22:03

Many thanks - useful ideas.

Yes, our other (Django-based) system would notify Drupal of adds/drops and, really, I'm more familiar with coding for the other system than I am for Drupal... so I just wondered if there was some standard way to add/remove users. But authenticating against the django system is also an option; I'll have a look at hhtpauth (and, now, securesite)

Thanks again.

Solution...

quentinsf - August 17, 2009 - 20:57

OK, just for reference, it looks as if the best solution for me will be an XML-RPC hook, and I've created a module which does it - in case it's useful for anyone else:

http://github.com/quentinsf/remote_user_manager/

 
 

Drupal is a registered trademark of Dries Buytaert.