From 6d861f6189bd5eb8f28464bccd60da9d450ae8e4 Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Tue, 4 Sep 2007 22:03:33 +0000 Subject: [PATCH] Merged in from DEV trunk... --- plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php b/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php index b3c88d2..05caedb 100644 --- a/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php +++ b/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php @@ -235,9 +235,16 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { ); $this->oValidator->notError($aResults); + $sUserName = $aResults[$this->aAttributes[1]]; + // With LDAP, if the 'uid' is null then try using the 'givenname' instead. + // See activedirectoryauthenticationprovider.inc.php and ldapauthenticationprovider.inc.php for details. + if($this->sAuthenticatorClass == "KTLDAPAuthenticator" && empty($sUserName)) { + $sUserName = strtolower($aResults[$this->aAttributes[2]]); + } + $fields = array(); $fields[] = new KTStaticTextWidget(_kt('LDAP DN'), _kt('The location of the user within the LDAP directory.'), 'dn', $id, $this->oPage); - $fields[] = new KTStringWidget(_kt('Username'), sprintf(_kt('The username the user will enter to gain access to %s. e.g. jsmith'), APP_NAME), 'ldap_username', $aResults[$this->aAttributes[1]], $this->oPage, true); + $fields[] = new KTStringWidget(_kt('Username'), sprintf(_kt('The username the user will enter to gain access to %s. e.g. jsmith'), APP_NAME), 'ldap_username', $sUserName, $this->oPage, true); $fields[] = new KTStringWidget(_kt('Name'), _kt('The full name of the user. This is shown in reports and listings. e.g. John Smith'), 'name', $aResults[$this->aAttributes[0]], $this->oPage, true); $fields[] = new KTStringWidget(_kt('Email Address'), _kt('The email address of the user. Notifications and alerts are mailed to this address if email notifications is set below. e.g. jsmith@acme.com'), 'email_address', $aResults[$this->aAttributes[4]], $this->oPage, false); $fields[] = new KTCheckboxWidget(_kt('Email Notifications'), _kt('If this is specified then the user will have notifications sent to the email address entered above. If it is not set, then the user will only see notifications on the Dashboard'), 'email_notifications', true, $this->oPage, false); @@ -307,14 +314,29 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']); $oAuthenticator = $this->getAuthenticator($oSource); $aNames = array(); + foreach ($aIds as $sId) { $aResults = $oAuthenticator->getUser($sId); $dn = $sId; $sUserName = $aResults[$this->aAttributes[1]]; + // With LDAP, if the 'uid' is null then try using the 'givenname' instead. + // See activedirectoryauthenticationprovider.inc.php and ldapauthenticationprovider.inc.php for details. + if($this->sAuthenticatorClass == "KTLDAPAuthenticator" && empty($sUserName)) { + $sUserName = strtolower($aResults[$this->aAttributes[2]]); + } $sName = $aResults[$this->aAttributes[0]]; $sEmailAddress = $aResults[$this->aAttributes[4]]; $sMobileNumber = $aResults[$this->aAttributes[5]]; + // If the user already exists append some text so the admin can see the duplicates. + $appending = true; + while($appending) { + if(!PEAR::isError(User::getByUserName($sUserName))) { + $sUserName = $sUserName . "_DUPLICATE"; + $appending = true; + } else $appending = false; + } + $oUser = User::createFromArray(array( "Username" => $sUserName, "Name" => $sName, -- libgit2 0.21.4