function createLdapAuthenticationProvider() { if (!file_exists(KT_DIR . '/config/environment.php')) { return; } global $default; $new_default = $default; $default = null; require_once KT_DIR . '/config/environment.php'; $old_default = $default; $default = $new_default; if ($old_default->authenticationClass !== "LDAPAuthenticator") { return; } $sName = "Autocreated by upgrade"; $sNamespace = KTUtil::nameToLocalNamespace("authenticationsources", $sName); $aConfig = array('searchattributes' => split(',', 'cn,mail,sAMAccountName'), 'objectclasses' => split(',', 'user,inetOrgPerson,posixAccount'), 'servername' => $old_default->ldapServer, 'basedn' => $old_default->ldapRootDn, 'searchuser' => $old_default->ldapSearchUser, 'searchpassword' => $old_default->ldapSearchPassword); if ($old_default->ldapServerType == "ActiveDirectory") { $sProvider = "ktstandard.authentication.adprovider"; } else { $sProvider = "ktstandard.authentication.ldapprovider"; } require_once KT_LIB_DIR . '/authentication/authenticationsource.inc.php'; $oSource = KTAuthenticationSource::createFromArray(array('name' => $sName, 'namespace' => $sNamespace, 'config' => serialize($aConfig), 'authenticationprovider' => $sProvider)); if (PEAR::isError($oSource)) { return $oSource; } $sUsersTable = KTUtil::getTableName('users'); $sQuery = "UPDATE {$sUsersTable} SET authentication_source_id = ? WHERE authentication_source_id IS NULL AND LENGTH(authentication_details_s1)"; $aParams = array($oSource->getId()); $res = DBUtil::runQuery(array($sQuery, $aParams)); return $res; }
function do_newsource_final() { $aErrorOptions = array('redirect_to' => array('main')); $aErrorOptions['message'] = _kt("No name provided"); $sName = KTUtil::arrayGet($_REQUEST, 'name'); $sName = $this->oValidator->validateString($sName, $aErrorOptions); $aErrorOptions['message'] = _kt("No authentication provider chosen"); $sProvider = KTUtil::arrayGet($_REQUEST, 'authentication_provider'); $sProvider = $this->oValidator->validateString($sProvider, $aErrorOptions); $sNamespace = KTUtil::nameToLocalNamespace($sName, 'authentication/sources'); $sConfig = ""; $oSource =& KTAuthenticationSource::createFromArray(array('name' => $sName, 'namespace' => $sNamespace, 'authenticationprovider' => $sProvider)); $this->oValidator->notError($oSource); $this->successRedirectTo('editSourceProvider', _kt("Source created"), sprintf('source_id=%d', $oSource->getId())); }