예제 #1
0
 function do_addUserFromSource()
 {
     $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('User Management'));
     $this->aBreadcrumbs[] = array('url' => KTUtil::addQueryStringSelf('action=addUser'), 'name' => _kt('add a new user'));
     $oProvider->aBreadcrumbs = $this->aBreadcrumbs;
     $oProvider->oPage->setBreadcrumbDetails($oSource->getName());
     $oProvider->oPage->setTitle(_kt("Add New User"));
     $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 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);
 }
 function &getForUser($oUser)
 {
     $oUser =& KTUtil::getObject('User', $oUser);
     $iAuthenticationSourceId = $oUser->getAuthenticationSourceId();
     if (empty($iAuthenticationSourceId)) {
         return null;
     }
     return KTAuthenticationSource::get($iAuthenticationSourceId);
 }
<?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);