Esempio n. 1
0
 function do_main()
 {
     $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('User Management'));
     $this->oPage->setBreadcrumbDetails(_kt('select a user'));
     $this->oPage->setTitle(_kt("User Management"));
     $KTConfig =& KTConfig::getSingleton();
     $alwaysAll = $KTConfig->get("alwaysShowAll");
     $name = KTUtil::arrayGet($_REQUEST, 'search_name', KTUtil::arrayGet($_REQUEST, 'old_search'));
     $show_all = KTUtil::arrayGet($_REQUEST, 'show_all', $alwaysAll);
     $user_id = KTUtil::arrayGet($_REQUEST, 'user_id');
     $no_search = true;
     if (KTUtil::arrayGet($_REQUEST, 'do_search', false) != false) {
         $no_search = false;
     }
     if ($name == '*') {
         $show_all = true;
         $name = '';
     }
     $search_fields = array();
     $search_fields[] = new KTStringWidget(_kt('Username'), _kt("Enter part of the person's username.  e.g. <strong>ra</strong> will match <strong>brad</strong>."), 'search_name', $name, $this->oPage, true);
     // FIXME handle group search stuff.
     $search_results = null;
     if (!empty($name)) {
         $search_results =& User::getList('WHERE username LIKE \'%' . DBUtil::escapeSimple($name) . '%\' AND id > 0');
     } else {
         if ($show_all !== false) {
             $search_results =& User::getList('id > 0');
             $no_search = false;
             $name = '*';
         }
     }
     $aAuthenticationSources =& KTAuthenticationSource::getList();
     $bCanAdd = true;
     if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
         $path = KTPluginUtil::getPluginPath('ktdms.wintools');
         require_once $path . 'baobabkeyutil.inc.php';
         $bCanAdd = BaobabKeyUtil::canAddUser();
         if (PEAR::isError($bCanAdd)) {
             $bCanAdd = false;
         }
     }
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("ktcore/principals/useradmin");
     $aTemplateData = array("context" => $this, "search_fields" => $search_fields, "search_results" => $search_results, "no_search" => $no_search, "authentication_sources" => $aAuthenticationSources, "old_search" => $name, "can_add" => $bCanAdd);
     return $oTemplate->render($aTemplateData);
 }
 function do_addsource()
 {
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/authentication/addsource');
     $fields = array();
     $fields[] = new KTStringWidget(_kt('Name'), _kt('A short name which helps identify this source of authentication data.'), 'name', "", $this->oPage, true);
     $aVocab = array();
     $oRegistry =& KTAuthenticationProviderRegistry::getSingleton();
     $aProviders = $oRegistry->getAuthenticationProvidersInfo();
     foreach ($aProviders as $aProvider) {
         $aVocab[$aProvider[2]] = $aProvider[0];
     }
     $fieldOptions = array("vocab" => $aVocab);
     $fields[] = new KTLookupWidget(_kt('Authentication provider'), _kt('The type of source (e.g. <strong>LDAP</strong>)'), 'authentication_provider', null, $this->oPage, true, null, $fieldErrors, $fieldOptions);
     $aSources = KTAuthenticationSource::getList();
     $oTemplate->setData(array('context' => &$this, 'fields' => $fields, 'providers' => $aProviders, 'sources' => $aSources));
     return $oTemplate->render();
 }
Esempio n. 3
0
 function do_addGroup()
 {
     $this->oPage->setBreadcrumbDetails(_kt('Add a new group'));
     $aAuthenticationSources = array();
     $aAllAuthenticationSources =& KTAuthenticationSource::getList();
     foreach ($aAllAuthenticationSources as $oSource) {
         $sProvider = $oSource->getAuthenticationProvider();
         $oRegistry =& KTAuthenticationProviderRegistry::getSingleton();
         $oProvider =& $oRegistry->getAuthenticationProvider($sProvider);
         if ($oProvider->bGroupSource) {
             $aAuthenticationSources[] = $oSource;
         }
     }
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("ktcore/principals/addgroup");
     $aTemplateData = array("context" => $this, "add_fields" => $add_fields, "authentication_sources" => $aAuthenticationSources, 'form' => $this->form_addgroup());
     return $oTemplate->render($aTemplateData);
 }
Esempio n. 4
0
 * 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);
}