How to implement a custom hook
Putting aside the general design of your application, you are right to use drupal_alter to provide a hook.

However, you are missing the correct hook implementation function name.

It should be:

drupal_alter('retrieve_login_extra_params', $params);
// ...
function MODULE_retrieve_login_extra_params_alter(&amp;$params){
// ...
}


You may also be interested in:


LDAP Integration
user_external_login_register