Skip to content

Instantly share code, notes, and snippets.

@markwylde
Last active January 26, 2018 15:07
Show Gist options
  • Save markwylde/0b9e9ce39a07a59c368e9311093ca1b7 to your computer and use it in GitHub Desktop.
Save markwylde/0b9e9ce39a07a59c368e9311093ca1b7 to your computer and use it in GitHub Desktop.

DeskPro - LDAP Bug

This file describes an error we have discovered while researching the DeskPro application.

The issue

When the LDAP plugin runs, it querys the LDAP server to fetch a list of all users objects.

The PHP application loops through all of the records, and then processes them. In this loop, at the very start, it moves the dataset cursor to the next record. Unfortunatly this runs before the first record has had a chance to run.

Our fix instructions

Open the file:

app/31909/src/Application/DeskPRO/Usersource/Sync/Syncer/LdapSyncer.php

Find the line (for me it is on line 154):

for ($i = 1; $records->valid(); ++$i) {

Directly under you will see the following code block:

try {
    $records->next();
} catch (LdapException $e) {
}

We have replaced this with:

try {
    if ($i > 1) {
        $records->next();
    }
} catch (LdapException $e) {
}

How our fix works

Our code prevents the recordset from moving to the next record, unless the first has been processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment