Commit fab2e525667361f03767eb087adcea9c3e1fac08

Authored by Neil Blakey-Milner
1 parent e4b1a623

Make everything more configurable.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5202 c91229c3-7414-0410-bfa2-8a42b809f60b
examples/fieldsynchronisation/syncFieldFromLDAP.php
... ... @@ -34,6 +34,9 @@ require_once(KT_LIB_DIR . '/authentication/authenticationsource.inc.php');
34 34 $sSourceName = "ActiveDirectory";
35 35 $sFieldsetNamespace = "http://ktcvs.local/local/fieldsets/synctestfieldset";
36 36 $sFieldName = "synctest";
  37 +$sSearch = "(objectClass=organizationalPerson)";
  38 +$sAttribute = "cn";
  39 +$sRootDN = null;
37 40  
38 41 $aAuthenticationSources =& KTAuthenticationSource::getList();
39 42 $oSource = null;
... ... @@ -63,19 +66,17 @@ $oLdap =& $oAuthenticator->oLdap;
63 66  
64 67 $aParams = array(
65 68 'scope' => 'sub',
66   - 'attributes' => array('cn'),
  69 + 'attributes' => array($sAttribute),
67 70 );
68   -$rootDn = $oKTConfig->get("ldap/ldapRootDn");
69   -if (is_array($rootDn)) {
70   - $rootDn = join(",", $rootDn);
71   -}
72   -$aResults = $oLdap->search($rootDn, '(objectClass=organizationalPerson)', $aParams);
  71 +
  72 +$aResults = $oLdap->search($sRootDn, $sSearch, $aParams);
73 73  
74 74 $aValues = array();
75 75 foreach ($aResults->entries() as $oEntry) {
76 76 // print $oEntry->dn() . "\n";
77   - $sValue = $oEntry->get_value('cn', 'single');
  77 + $sValue = $oEntry->get_value($sAttribute, 'single');
78 78 // print $sValue . "\n";
79 79 $aValues[] = $sValue;
80 80 }
  81 +
81 82 KTMetadataUtil::synchroniseMetadata($oField, $aValues);
... ...