login which will be 0 if the user has never * logged in before. * * The 'cas_user' key in $edit contains all information returned from * hook_cas_user_alter(). * * The CAS module promises to call user_save() and user_login_finalize() with * this $edit data. * * @param $edit * An array of values corresponding to the Drupal user to be created. * @param $account * A Druapl user object. */ function hook_cas_user_presave(&$edit, $account) { $cas_name = $edit['cas_user']['name']; // Look up the user's real name using LDAP. $ldap_connection = ldap_connect('ldap.example.com', 389); $ldap_result = ldap_search($ldap_connection, 'ou=people', 'uid=' . $cas_name, array('cn'), 0, 1); $entries = ldap_get_entries($ldap_connection, $ldap_result); $attributes = $entries[0]; if (!empty($attributes['cn'])) { $edit['name'] = $attributes['cn']; } } /** * Modify phpCAS authentication properties. * * This is called after phpCAS has been configured with the basic server * properties, but before phpCAS::forceAuthentication() is called. * * Users will generally not need to implement this hook, as most phpCAS * configuration options are already provided in the CAS module UI. * * There are no parameters, instead the module should directly call the * functions in the phpCAS namespace. */ function hook_cas_phpcas_alter() { // Set a custom server login URL. phpCAS::setServerLoginURL('https://login.example.com/cas/login'); }