We help IT Professionals succeed at work.

PHP to Query LDAP, check if memberof against a paramater

adznon
adznon asked
on
56 Views
Last Modified: 2018-12-12
I am using PHP to search a LDAP member of list to see if a user is a member of a group "GG-UK-Pink-Stores 2136 StoreManager" and then if they are a member pull out the four digit store number.

It works however it doesnt seem to check for the StoreManager and bring back anything similar.

// *****************************************************
// Searches for the Key of Store Manager within the array.
// *****************************************************
      $keysval = ['StoreManager'];
      foreach($ldapGroups[0]['memberof'] as $k => $v) {
        if ($k === 'count') continue;
        echo $v . "<br>";
        if (preg_match('/.*? (\d\d\d\d) .*/', $v, $match)) {
            $keyval[$match[1]] = true;
        }
        
      }
      $retailOutletNumbers = array_keys($keyval)
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Perfect, many thanks
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
You are welcome.