<?php require_once '../../../../config/dmsDefaults.php'; require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; require_once KT_LIB_DIR . '/authentication/authenticationsource.inc.php'; require_once 'Net/LDAP.php'; $oKTConfig =& KTConfig::getSingleton(); $oAuthenticator = KTAuthenticationUtil::getAuthenticatorForSource(2); $config = array('dn' => $oAuthenticator->sSearchUser, 'password' => $oAuthenticator->sSearchPassword, 'host' => $oAuthenticator->sLdapServer, 'base' => $oAuthenticator->sBaseDN); $oLdap =& Net_LDAP::connect($config); if (PEAR::isError($oLdap)) { var_dump($oLdap); exit(0); } $aParams = array('scope' => 'sub', 'attributes' => array('cn', 'dn', 'displayClass')); $rootDn = $oAuthenticator->sBaseDN; if (is_array($rootDn)) { $rootDn = join(",", $rootDn); } $oResults = $oLdap->search($rootDn, '(objectClass=group)', $aParams); foreach ($oResults->entries() as $oEntry) { var_dump($oEntry->dn()); }
} } 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); } $oField = DocumentField::getByFieldsetAndName($oFieldset, $sFieldName); if (PEAR::isError($oField)) { printf("No field named %s found in fieldset %s\n", $sFieldName, $sFieldsetNamespace); exit(1); } $oAuthenticator =& KTAuthenticationUtil::getAuthenticatorForSource($oSource); $oLdap =& $oAuthenticator->oLdap; $aParams = array('scope' => 'sub', 'attributes' => array($sAttribute)); $aResults = $oLdap->search($sRootDn, $sSearch, $aParams); $aValues = array(); foreach ($aResults->entries() as $oEntry) { // print $oEntry->dn() . "\n"; $sValue = $oEntry->get_value($sAttribute, 'single'); // print $sValue . "\n"; if (!empty($sValue)) { $aValues[] = $sValue; } } $aValues = array_unique($aValues); KTMetadataUtil::synchroniseMetadata($oField, $aValues);
function synchroniseGroupToSource($oGroup) { $oGroup =& KTUtil::getObject('Group', $oGroup); $iSourceId = $oGroup->getAuthenticationSourceId(); $oAuthenticator = KTAuthenticationUtil::getAuthenticatorForSource($iSourceId); return $oAuthenticator->synchroniseGroup($oGroup); }