public function incrementalFetch($uSNChangedFrom, $uSNChangedTo, $detectDeleted = false)
    {
        // fetch changed
        $changedFilter = Filter::andFilter(
            Filter::greaterOrEqual('uSNChanged', $uSNChangedFrom),
            Filter::lessOrEqual('uSNChanged', $uSNChangedTo)
        );
        if ($this->incrementalSyncEntryFilter) {
            $changedFilter = $changedFilter->addAnd($this->incrementalSyncEntryFilter);
        }
        $changed = $this->search($changedFilter);

        // fetch deleted
        $deleted = [];
        if ($detectDeleted) {
            $defaultNamingContext = $this->getRootDse()->getDefaultNamingContext();
            $options              = $this->ldap->getOptions();
            $originalHost         = isset($options['host']) ? $options['host'] : '';
            $hostForDeleted = rtrim($originalHost, "/") . "/" .urlencode(
                    sprintf("<WKGUID=%s,%s>", self::WK_GUID_DELETED_OBJECTS_CONTAINER_W, $defaultNamingContext)
                )
            ;

            // hack that workarounds zendframework/zend-ldap connection issues.
            // should be removed after resolution of https://github.com/zendframework/zend-ldap/pull/69
            if (!preg_match('~^ldap(?:i|s)?://~', $hostForDeleted)) {
                $schema = "ldap://";
                if ((isset($options['port']) && $options['port'] == 636) || (isset($options['useSsl']) && $options['useSsl'] == true)) {
                    $schema = "ldaps://";
                }
                $hostForDeleted = $schema.$hostForDeleted;
            }
            // end of hack

            $options['host'] = $hostForDeleted;

            // force reconnection for search of deleted entries
            $this->ldap->setOptions($options);
            $this->ldap->disconnect();

            $deletedFilter = Filter::andFilter(
                Filter::equals('isDeleted', 'TRUE'),
                Filter::greaterOrEqual('uSNChanged', $uSNChangedFrom),
                Filter::lessOrEqual('uSNChanged', $uSNChangedTo)
            );
            if ($this->deletedSyncEntryFilter) {
                $deletedFilter = $deletedFilter->addAnd($this->deletedSyncEntryFilter);
            }
            $deleted = $this->search($deletedFilter);
        }

        return [$changed, $deleted];
    }
public function incrementalFetch($uSNChangedFrom, $uSNChangedTo, $detectDeleted = false)
    {
        // fetch changed
        $changedFilter = Filter::andFilter(
            Filter::greaterOrEqual('uSNChanged', $uSNChangedFrom),
            Filter::lessOrEqual('uSNChanged', $uSNChangedTo)
        );
        if ($this->incrementalSyncEntryFilter) {
            $changedFilter = $changedFilter->addAnd($this->incrementalSyncEntryFilter);
        }
        $changed = $this->search($changedFilter);

        // fetch deleted
        $deleted = [];
        if ($detectDeleted) {
            $defaultNamingContext = $this->getRootDse()->getDefaultNamingContext();
            $options              = $this->ldap->getOptions();
            $originalHost         = isset($options['host']) ? $options['host'] : '';
            $hostForDeleted = rtrim($originalHost, "/") . "/" .urlencode(
                    sprintf("<WKGUID=%s,%s>", self::WK_GUID_DELETED_OBJECTS_CONTAINER_W, $defaultNamingContext)
                )
            ;

            // hack that workarounds zendframework/zend-ldap connection issues.
            // should be removed after resolution of https://github.com/zendframework/zend-ldap/pull/69
            if (!preg_match('~^ldap(?:i|s)?://~', $hostForDeleted)) {
                $schema = "ldap://";
                if ((isset($options['port']) && $options['port'] == 636) || (isset($options['useSsl']) && $options['useSsl'] == true)) {
                    $schema = "ldaps://";
                }
                $hostForDeleted = $schema.$hostForDeleted;
            }
            // end of hack

            $options['host'] = $hostForDeleted;

            // force reconnection for search of deleted entries
            $this->ldap->setOptions($options);
            $this->ldap->disconnect();

            $deletedFilter = Filter::andFilter(
                Filter::equals('isDeleted', 'TRUE'),
                Filter::greaterOrEqual('uSNChanged', $uSNChangedFrom),
                Filter::lessOrEqual('uSNChanged', $uSNChangedTo)
            );
            if ($this->deletedSyncEntryFilter) {
                $deletedFilter = $deletedFilter->addAnd($this->deletedSyncEntryFilter);
            }
            $deleted = $this->search($deletedFilter);
        }

        return [$changed, $deleted];
    }
public function incrementalFetch ( $ uSNChangedFrom , $ uSNChangedTo , $ detectDeleted = false ) { // fetch changed $ changedFilter = Filter :: andFilter ( Filter :: greaterOrEqual ( 'uSNChanged' , $ uSNChangedFrom ) , Filter :: lessOrEqual ( 'uSNChanged' , $ uSNChangedTo ) ) ; if ( $ this -> incrementalSyncEntryFilter ) { $ changedFilter = $ changedFilter -> addAnd ( $ this -> incrementalSyncEntryFilter ) ; } $ changed = $ this -> search ( $ changedFilter ) ; // fetch deleted $ deleted = [ ] ; if ( $ detectDeleted ) { $ defaultNamingContext = $ this -> getRootDse ( ) -> getDefaultNamingContext ( ) ; $ options = $ this -> ldap -> getOptions ( ) ; $ originalHost = isset ( $ options [ 'host' ] ) ? $ options [ 'host' ] : '' ; $ hostForDeleted = rtrim ( $ originalHost , "/" ) . "/" . urlencode ( sprintf ( "<WKGUID=%s,%s>" , self :: WK_GUID_DELETED_OBJECTS_CONTAINER_W , $ defaultNamingContext ) ) ; // hack that workarounds zendframework/zend-ldap connection issues. // should be removed after resolution of https://github.com/zendframework/zend-ldap/pull/69 if ( ! preg_match ( '~^ldap(?:i|s)?://~' , $ hostForDeleted ) ) { $ schema = "ldap://" ; if ( ( isset ( $ options [ 'port' ] ) && $ options [ 'port' ] == 636 ) || ( isset ( $ options [ 'useSsl' ] ) && $ options [ 'useSsl' ] == true ) ) { $ schema = "ldaps://" ; } $ hostForDeleted = $ schema . $ hostForDeleted ; } // end of hack $ options [ 'host' ] = $ hostForDeleted ; // force reconnection for search of deleted entries $ this -> ldap -> setOptions ( $ options ) ; $ this -> ldap -> disconnect ( ) ; $ deletedFilter = Filter :: andFilter ( Filter :: equals ( 'isDeleted' , 'TRUE' ) , Filter :: greaterOrEqual ( 'uSNChanged' , $ uSNChangedFrom ) , Filter :: lessOrEqual ( 'uSNChanged' , $ uSNChangedTo ) ) ; if ( $ this -> deletedSyncEntryFilter ) { $ deletedFilter = $ deletedFilter -> addAnd ( $ this -> deletedSyncEntryFilter ) ; } $ deleted = $ this -> search ( $ deletedFilter ) ; } return [ $ changed , $ deleted ] ; }
Performs incremental fetch

@param integer $uSNChangedFrom min usnChanged value to restrict objects search
@param integer $uSNChangedTo   max usnChanged value to restrict objects search
@param bool    $detectDeleted  whether deleted entries should be fetched or not

@return array with following structure:
[
$changed, // list of changed entries
$deleted  // list of deleted entries
]
Performs incremental fetch