Link to home
Start Free TrialLog in
Avatar of adznon
adznon

asked on

PHP to Query LDAP, check if memberof against a paramater

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)
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adznon
adznon

ASKER

Perfect, many thanks
You are welcome.