1. Go to this page and download the library: Download gtt/ad-poller library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gtt / ad-poller example snippets
// configure ldap connector
$ldapConnector = new Ldap(
// Connector options. @see https://github.com/zendframework/zend-ldap for details
[
'host' => 'ldap.myorg.com',
'username' => '[email protected]',
'password' => 'secret',
'accountDomainName' => 'ldap.myorg.com',
'baseDn' => 'DC=myorg,DC=com'
]
);
// configure ldap fetcher
$ldapFetcher = new \Gtt\ADPoller\Fetch\LdapFetcher(
$ldapConnector,
// Optional ldap filter describes entries to fetch during full sync
'&(objectClass=user)(objectCategory=person))',
// Optional ldap filter describes entries to fetch during incremental sync.
// It can differ from the previous one if you want track deactivatation of entities
// (during full sync you need only active, but here - not)
'&(objectClass=user)(objectCategory=person))',
// Optional ldap filter describes deleted entries to fetch during incremental sync
'&(objectClass=user)(objectCategory=person))',
// list of properties to be fetched
['cn', 'displayname','telephonenumber', 'description']
);
// you also can specify additional ldap search options here if you need, for example:
$ldapFetcher->setLdapSearchOptions(LDAP_OPT_SERVER_CONTROLS, [['oid' => '1.2.840.113556.1.4.529']]);
// configure entity manager to persist poll tasks
$em = \Doctrine\ORM\EntityManager::create($conn, $config);
// configure synchronizer (use your own SynchronizerInterface implementation if needed)
$sync = new \Gtt\ADPoller\Sync\Events\EventSynchronizer(new \Symfony\Component\EventDispatcher\EventDispatcher());
// configure Poller itself
$poller = new Poller(
$ldapFetcher,
$sync,
$em,
// optionaly you can tell poller to fetch deleted entries
// @see https://msdn.microsoft.com/en-us/library/ms677927(v=vs.85).aspx for details
false
// optional poller name - use it if you have different pollers
'mypoller'
);
$poller->poll();
// bin/console (do not forget #!/usr/bin/env php at very first line)
// create poller collection
$pollerCollection = new \Gtt\ADPoller\PollerCollection();
// Add poller to collection:
$pollerCollection->addPoller($poller);
// create application and command
$application = new \Symfony\Component\Console\Application();
$application->add(new \Gtt\ADPoller\Command\PollCommand($pollerCollection));
$application->run();