Hello, hope someone can help me out. I am using the following php page to determine if a user belongs to a particular group, however it does not seem to be working, I cannot seem to get the script to detect whether or not the user belongs to the group, does anyone have any suggestion on how to get this to work?
<?php
ini_set('display_errors', 0);
//error_reporting(1);
error_reporting ('2147483647');
$arguments = getopt("u");
//print_r($arguments);
echo grouptestfull($arguments['u']);
function grouptestfull($user)
{
//print "processed username ".$user."<br><hr>";
//include("adLDAP.php");
require_once(dirname(__FILE__) . '/adLDAP.php');
$adldap = new adLDAP();
try {
$ldap_db = new adLDAP();
}
catch (adLDAPException $e)
{
echo $e; exit();
}
// clear the flags
$validhr = false;
$validinf = false;
$validroot = false;
//check group
//$test = $ldap_db->user_ingroup($user,"SD.HR", true);
//echo $test;
//die;
if(($ldap_db->user_ingroup($user,"HR Group", true)))
{
echo "\nvalidhr\n";
$validhr = true;
}
if(($ldap_db->user_ingroup($user,"INF Group", true)))
{
echo "\nvalidinf\n";
$validinf = true;
}
if(($ldap_db->user_ingroup($user,"ROOT Group", true)))
{
echo "\nvalidroot\n";
$validroot = true;
}
//sort and return highest lvl group membership
if ($validroot)
{
return "validroot";
echo "validroot"; //for testing only
}
else
{
echo "GOT HERE1"; //for testing only
if ($validinf)
{
return "validinf";
echo "validinf"; //for testing only
}
else
{
if ($validhr)
{
;
return "validhr";
echo "Validhr"; //for testing only
}
else
{
echo "null"; //for testing only
return "";
}
}
}
}
echo "GOT HERE2"; //for testing only
?>
It keeps returning Null so it does not appear to be finding the correct group for the user no matter who logs in to the site.
Thanks...