Checking two databases when logging in a user with a custom module
Never tried, but you can basicaly:


try hook_user() but you may not catch the case where the user doesn't exists in drupal but your other site.
create your own login form &amp; callback and:

check if user exists in drupal with user_external_load()
if user exists on your external site either login or register on drupal using user_external_login_register()



You may find some interesting code in the openid_authentication().