When my user tries to register, I'd like to make sure his information is valid, by checking an external identity repository (e.g. call a web service or look up a directory server).
Is that possible with any existing module? If not, what would be the best way to develop this functionality?
I'm not aware of an existing module allowing the addition of custom validation, but it is fairly easy to implement this using the 'validate' action of
hook_user()
:This would stop the registration process and redisplay the registration form with the error message on the mail field as long as
yourModule_custom_mail_validation()
does not return TRUE.If you want the validation to happen for existing users editing their account also, you could drop the
part from the first if clause - the code would then run for every user edit form submission, not just on registration.
If you are using an LDAP server to authenticate, there is the LDAP module. Check that out.
For authenticating with some other web service, you'll have to write a module and implement hook_user, particularly the 'login' case. If, upon login, the user's credentials do not match those in your web service, you can log them out and display a message, perhaps.