Commit bf2c972815e0148116e490526a73f0f0012e8552

Authored by Kevin Fourie
1 parent 5d35c629

KTS-2323

"DB Constraint Error when adding a duplicate user from an authentication source."
Fixed. Added duplicate user check.

Committed By: Kevin Fourie
Reviewed By: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7118 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php
... ... @@ -265,7 +265,11 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
265 265 if (empty($name)) { $this->errorRedirectToMain(_kt('You must specify a name for the user.')); }
266 266 $username = KTUtil::arrayGet($_REQUEST, 'ldap_username');
267 267 if (empty($username)) { $this->errorRedirectToMain(_kt('You must specify a new username.')); }
268   - // FIXME check for non-clashing usernames.
  268 +
  269 + $dupUser =& User::getByUserName($username);
  270 + if(!PEAR::isError($dupUser)) {
  271 + $this->errorRedirectToMain(_kt("A user with that username already exists"));
  272 + }
269 273  
270 274 $email_address = KTUtil::arrayGet($_REQUEST, 'email_address');
271 275 $email_notifications = KTUtil::arrayGet($_REQUEST, 'email_notifications', false);
... ... @@ -286,7 +290,7 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
286 290 "authenticationdetails2" => $samaccountname,
287 291 "password" => "",
288 292 ));
289   -
  293 +
290 294 if (PEAR::isError($oUser) || ($oUser == false)) {
291 295 $this->errorRedirectToMain(_kt("failed to create user") . ": " . $oUser->message);
292 296 exit(0);
... ...