function do_editUserSource() { $user_id = KTUtil::arrayGet($_REQUEST, 'user_id'); $oUser =& $this->oValidator->validateUser($user_id); $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('User Management')); $this->aBreadcrumbs[] = array('name' => $oUser->getName()); $oAuthenticationSource = KTAuthenticationSource::getForUser($oUser); if (is_null($oAuthenticationSource)) { $oProvider =& new KTBuiltinAuthenticationProvider(); } else { $sProvider = $oAuthenticationSource->getAuthenticationProvider(); $oRegistry =& KTAuthenticationProviderRegistry::getSingleton(); $oProvider = $oRegistry->getAuthenticationProvider($sProvider); } $oProvider->subDispatch($this); exit; }
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; }
* must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ * */ require_once '../../config/dmsDefaults.php'; require_once KT_LIB_DIR . '/metadata/metadatautil.inc.php'; require_once KT_LIB_DIR . '/authentication/authenticationsource.inc.php'; require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; $sSourceName = "ActiveDirectory"; $sFieldsetNamespace = "http://ktcvs.local/local/fieldsets/synctestfieldset"; $sFieldName = "synctest"; $sSearch = "(objectClass=organizationalPerson)"; $sAttribute = "cn"; $sRootDN = null; $aAuthenticationSources =& KTAuthenticationSource::getList(); $oSource = null; foreach ($aAuthenticationSources as $oPotentialSource) { if ($oPotentialSource->getName() == $sSourceName) { $oSource =& $oPotentialSource; } } if (empty($oSource)) { printf("No authentication source named %s found\n", $sSourceName); exit(1); } $oFieldset =& KTFieldset::getByNamespace($sFieldsetNamespace); if (PEAR::isError($oFieldset)) { printf("No fieldset named %s found\n", $sFieldsetNamespace); exit(1); }
function do_addGroupFromSource() { $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']); $sProvider = $oSource->getAuthenticationProvider(); $oRegistry =& KTAuthenticationProviderRegistry::getSingleton(); $oProvider =& $oRegistry->getAuthenticationProvider($sProvider); $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Group Management')); $this->aBreadcrumbs[] = array('url' => KTUtil::addQueryStringSelf('action=addGroup'), 'name' => _kt('add a new group')); $oProvider->aBreadcrumbs = $this->aBreadcrumbs; $oProvider->oPage->setBreadcrumbDetails($oSource->getName()); $oProvider->oPage->setTitle(_kt("Modify Group Details")); $oProvider->dispatch(); exit(0); }
function _do_createGroupFromSource() { $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']); $dn = KTUtil::arrayGet($_REQUEST, 'dn'); $name = KTUtil::arrayGet($_REQUEST, 'ldap_groupname'); if (empty($name)) { $this->errorRedirectToMain(_kt('You must specify a name for the group.')); } $is_unitadmin = KTUtil::arrayGet($_REQUEST, 'is_unitadmin', false); $is_sysadmin = KTUtil::arrayGet($_REQUEST, 'is_sysadmin', false); $oGroup =& Group::createFromArray(array("name" => $name, "isunitadmin" => $is_unitadmin, "issysadmin" => $is_sysadmin, "authenticationdetails" => $dn, "authenticationsourceid" => $oSource->getId())); if (PEAR::isError($oGroup) || $oGroup == false) { $this->errorRedirectToMain(_kt("failed to create group.")); exit(0); } $oAuthenticator = $this->getAuthenticator($oSource); $oAuthenticator->synchroniseGroup($oGroup); $this->successRedirectToMain(_kt('Created new group') . ': ' . $oGroup->getName()); exit(0); }
function &getForUser($oUser) { $oUser =& KTUtil::getObject('User', $oUser); $iAuthenticationSourceId = $oUser->getAuthenticationSourceId(); if (empty($iAuthenticationSourceId)) { return null; } return KTAuthenticationSource::get($iAuthenticationSourceId); }
function autoSignup($sUsername, $sPassword, $aExtra) { $aSources = KTAuthenticationSource::getSources(); foreach ($aSources as $oSource) { $oProvider = KTAuthenticationUtil::getAuthenticationProviderForSource($oSource); $res = $oProvider->autoSignup($sUsername, $sPassword, $aExtra, $oSource); if ($res) { return $res; } } return false; }
function do_performEditSourceProvider() { $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']); $sProvider = $oSource->getAuthenticationProvider(); $oRegistry =& KTAuthenticationProviderRegistry::getSingleton(); $oProvider =& $oRegistry->getAuthenticationProvider($sProvider); $this->aBreadcrumbs[] = array('name' => $oSource->getName(), 'url' => KTUtil::addQueryStringSelf("source_id=" . $oSource->getId())); $oProvider->subDispatch($this); exit(0); }
<?php require_once "../../config/dmsDefaults.php"; require_once KT_LIB_DIR . '/authentication/authenticationsource.inc.php'; require_once KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php'; $oSource = KTAuthenticationSource::get(2); $sProvider = $oSource->getAuthenticationProvider(); $oRegistry = KTAuthenticationProviderRegistry::getSingleton(); $oProvider =& $oRegistry->getAuthenticationProvider($sProvider); $oAuthenticator = $oProvider->getAuthenticator($oSource); $oUser = User::getByUserName('nbm'); $foo = $oAuthenticator->checkPassword($oUser, 'asdfa'); var_dump($foo);