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`;
}
}