0
votes

How to get memberof the user filter? Not all users have memberof.

$ds = `000.000.000.000`;
$ldaprdn  = `CN=Users,dc=xxx,dc=xx,dc=xx,dc=xx`;    
$user = `CN=UserSystem,`;
$ldappass = `pass`;

// connect to ldap server
$ldapconn = ldap_connect("000.000.000.000") or die(`Could not connect to LDAP server.`);

if ($ldapconn) {
    // binding to ldap server
    $ldapbind = ldap_bind($ldapconn, $user.``.$ldaprdn, $ldappass);
    // verify binding
    if ($ldapbind) {        
        ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3);
        ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0);

        $sr=ldap_search($ldapconn, $ldaprdn, `(&(objectClass=user)(sAMAccountName=testuser))`);
        $info = ldap_get_entries($ldapconn, $sr);

        $ii=0;
         for ($i=0; $ii`;
              if ($data == `memberof`) {
            $membrog = explode(`,`, $info[$i][$data][0]);
            $membrode = explode(`=`, $membrog[0]);
            echo $membrode[1].`
`; } } ldap_close($ldapconn); } else { echo `Connection to LDAP Failed`; } }
1
What results are you getting with this code?kdmurray
Some users filter memberof others not. memberof:CN=Imageadmin,OU=Image,OU=System,OU=Groups,DC=xx,DC=xx,DC=xx,DC=xxEder

1 Answers

0
votes

If you are looking at groups a user is a memberOF, from LDAP, Because of group nesting, you may need to use a filter which utilizes MATCHING_RULE_IN_CHAIN, like shown on this page.

-jim