承接 gtt/ad-poller 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gtt/ad-poller

Composer 安装命令:

composer require gtt/ad-poller

包简介

Polls Active Directory through ldap and dispatches payload using event dispatcher

README 文档

README

Build Status Latest Stable Version Latest Unstable Version License

This package is PHP implementation of algorithm of polling for changes in Active Directory servers using uSNChanged attribute with additional features allowing custom adjustments for Active Directory fetching processes and changesets handling.

The main usage purpose is to keep you application in sync with Active Directory structure.

Overview

The core concept is to constantly poll Active Directory server and perform incremental fetch to obtain changesets using uSNChanged attribute as an offset. Each poll task run is persisted in database to save the offset and fetch statistics. In case of Active Directory controller swap, server failures or initial run algorithm performs full fetch to obtain the fullset. Received data is subject to deliver to the target application to be handled.

The component consists of three main parts: poller, fetcher and synchronizer.

Poller

This is a heart of the library and base implementation of original polling algorithm. Uses fetcher to interact with Active Directory Server in order to fetch changesets and synchronizer to process obtained changesets.

See Poller implementation for details.

Fetcher

This part is responsible to interact with Active Directory. Allows poller to fetch neccessary metadata from Active Directory and search changesets using zendframework/zend-ldap.

See LdapFetcher implementation for details.

Synchronizer

Synchronizer is about handling datasets received during polling process. Base implementation uses symfony/event-dispatcher to publish changesets/fullset as an Events. For incremental sync there is a IncrementalSyncEvent, for full sync - FullSyncEvent.

See EventSynchronizer implementation for details.

Component provides SynchronizerInterface which allows implementation of your own synchronizer for custom aims.

Setup and usage

Package installation

To install the package use composer:

composer require gtt/ad-poller

Database setup

It is possible to generate schema using doctrine console utils. You can clone the repository from scratch, adjust cli-config.php with credentials to your test database and generate init sql:

composer install && php ./vendor/bin/doctrine orm:schema-tool:create --dump-sql

Application setup

Create poller:

// configure ldap connector
$ldapConnector = new Ldap(
    // Connector options. @see https://github.com/zendframework/zend-ldap for details
    [
        'host' => 'ldap.myorg.com',
        'username' => 'poller@ldap.myorg.com',
        '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'
);

You also can create as many pollers as you want with different settings depending on your needs.

Now you can poll Active Directory permanently (normally using crontab) runing something like this:

$poller->poll();

There is also console command that represents convenient way to run pollers with pretty output and additional options if you use use symfony/console:

// 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();

And put into crontab command to run all pollers:

php bin/console gtt:pollers:run

or concrete one:

php bin/console gtt:pollers:run --poller=mypoller

Framework integration

There is a gtt/ad-poller-bundle which integrates component in Symfony2+ ecosystem

Testing

To run library test suite just clone the repository and execute the following inside:

composer install && ./vendor/bin/phpunit

gtt/ad-poller 适用场景与选型建议

gtt/ad-poller 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 09 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 gtt/ad-poller 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gtt/ad-poller 我们能提供哪些服务?
定制开发 / 二次开发

基于 gtt/ad-poller 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 42
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 7
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-22