From bf2c972815e0148116e490526a73f0f0012e8552 Mon Sep 17 00:00:00 2001 From: Kevin Fourie Date: Tue, 4 Sep 2007 12:12:57 +0000 Subject: [PATCH] KTS-2323 "DB Constraint Error when adding a duplicate user from an authentication source." Fixed. Added duplicate user check. --- plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php b/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php index e8767c7..b3c88d2 100644 --- a/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php +++ b/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php @@ -265,7 +265,11 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { if (empty($name)) { $this->errorRedirectToMain(_kt('You must specify a name for the user.')); } $username = KTUtil::arrayGet($_REQUEST, 'ldap_username'); if (empty($username)) { $this->errorRedirectToMain(_kt('You must specify a new username.')); } - // FIXME check for non-clashing usernames. + + $dupUser =& User::getByUserName($username); + if(!PEAR::isError($dupUser)) { + $this->errorRedirectToMain(_kt("A user with that username already exists")); + } $email_address = KTUtil::arrayGet($_REQUEST, 'email_address'); $email_notifications = KTUtil::arrayGet($_REQUEST, 'email_notifications', false); @@ -286,7 +290,7 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { "authenticationdetails2" => $samaccountname, "password" => "", )); - + if (PEAR::isError($oUser) || ($oUser == false)) { $this->errorRedirectToMain(_kt("failed to create user") . ": " . $oUser->message); exit(0); -- libgit2 0.21.4