summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiglius Alaburda2010-10-13 11:03:26 (GMT)
committer Miglius Alaburda2010-10-13 11:03:26 (GMT)
commitb16d5e2fd87f99d9abb4c35211da5be8e7977abe (patch)
treec6c9336604211b116e0a459f08e4c3bb966e4e77
parent6afa43aa528088fc78922dc8a202945aa33f2baf (diff)
ldap_integration: ensured that ldap username is used on the drupal user creation, added a hook to be invoked on the user creation
-rw-r--r--ldapauth.module9
1 files changed, 8 insertions, 1 deletions
diff --git a/ldapauth.module b/ldapauth.module
index 4e77800..adf7495 100644
--- a/ldapauth.module
+++ b/ldapauth.module
@@ -330,12 +330,19 @@ function ldapauth_authenticate($form_values = array()) {
return;
}
+ // Use name as is set in the LDAP server.
+ $name_attr = $_ldapauth_ldap->getOption('user_attr') ? $_ldapauth_ldap->getOption('user_attr') : LDAPAUTH_DEFAULT_USER_ATTR;
+ $name_new = isset($ldap_user[$name_attr][0]) ? $ldap_user[$name_attr][0] : (isset($ldap_user[drupal_strtolower($name_attr)][0]) ? $ldap_user[drupal_strtolower($name_attr)][0] : $name);
+
// Generate a random drupal password. LDAP password will be used anyways.
$pass_new = (LDAPAUTH_LOGIN_PROCESS == LDAPAUTH_AUTH_EXCLUSIVED || !LDAPAUTH_SYNC_PASSWORDS) ? user_password(20) : $pass;
- $userinfo = array('name' => $name, 'pass' => $pass_new, 'mail' => $mail, 'init' => $init, 'status' => 1, 'authname_ldapauth' => $name, 'ldap_authentified' => TRUE, 'ldap_dn' => $ldap_user['dn'], 'ldap_config' => $_ldapauth_ldap->getOption('sid'));
+ $userinfo = array('name' => $name_new, 'pass' => $pass_new, 'mail' => $mail, 'init' => $init, 'status' => 1, 'authname_ldapauth' => $name, 'ldap_authentified' => TRUE, 'ldap_dn' => $ldap_user['dn'], 'ldap_config' => $_ldapauth_ldap->getOption('sid'));
$user = user_save('', $userinfo);
watchdog('ldapauth', 'New external user %name created from the LDAP server %server.', array('%name' => $name, '%server' => $_ldapauth_ldap->getOption('name')), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
+
+ // Invoke post user creation hook.
+ module_invoke_all('ldapauth_create', $user);
}
}
else {