Click to See Complete Forum and Search --> : Case Select Search.


endiz
11-18-2005, 01:44 PM
echo $v1; //CN=AGG_70463_VARadmin_Supervisor,DC=inside,DC=test,DC=ca

the CN= in the variable will be 3 seperate cases. How will I be able to search the variable and see if it includes either:

AGG_70463_VARadmin_Supervisor
AGG_70463_VARview_Restricted
AGG_70463_VARowner_GenUser

Or NONE. And set $group as that groupname.

Say for the $v1 example,

echo $group; //AGG_70463_VARadmin_Supervisor

Thanks guys.

JDM71488
11-18-2005, 01:58 PM
you could just pull the information from the URL like so:
if($_GET['CN'])
{
switch($_GET['CN'])
{
case "AGG_70463_VARadmin_Supervisor":
$group = $_GET['CN'];
break;

case "AGG_70463_VARview_Restricted":
$group = $_GET['CN'];
break;

case "AGG_70463_VARowner_GenUser":
$group = $_GET['CN'];
break;

default:
$group = "none";
break;
}
}
now, if you must search $v1, then you could use explode() and form an associative array...

help any?

endiz
11-18-2005, 02:07 PM
you could just pull the information from the URL like so:
if($_GET['CN'])
{
switch($_GET['CN'])
{
case "AGG_70463_VARadmin_Supervisor":
$group = $_GET['CN'];
break;

case "AGG_70463_VARview_Restricted":
$group = $_GET['CN'];
break;

case "AGG_70463_VARowner_GenUser":
$group = $_GET['CN'];
break;

default:
$group = "none";
break;
}
}
now, if you must search $v1, then you could use explode() and form an associative array...

help any?


The variable isn't passed from a URL though, Its getting it from an LDAP search.

Could you put explode() into context?

Thanks for the help.

SpectreReturns
11-18-2005, 02:22 PM
Try using parse_url on it, and then exploring the query string.

endiz
11-18-2005, 02:39 PM
Try using parse_url on it, and then exploring the query string.

The variable might have multiple CN= values, but only have 1 of the groups that is specified (AGG_70463_VARview_Restricted, AGG_70463_VARadmin_Supervisor, AGG_70463_VARowner_GenUser).

So, the variable might look like:

CN=TEST,CN=BLAH,CN=AAGG_70463_VARview_Restricted,OU=Groups,OU=Information Technology,DC=inside,DC=test,DC=ca


So it belongs to the AGG_70463_VARview_Restricted group, but also other groups.

Thanks.

NogDog
11-18-2005, 03:05 PM
You could do it with a regexp:

$groups = array('AGG_70463_VARadmin_Supervisor',
'AGG_70463_VARview_Restricted',
'AGG_70463_VARowner_GenUser');
$regexp = '/' . implode('|', $groups) . '/';
if(preg_match($regexp, $v1, $matches))
{
$group = $matches[0];
}
else
{
# handle situation where it's not found to be any of those groups
}

endiz
11-18-2005, 03:30 PM
You could do it with a regexp:

$groups = array('AGG_70463_VARadmin_Supervisor',
'AGG_70463_VARview_Restricted',
'AGG_70463_VARowner_GenUser');
$regexp = '/' . implode('|', $groups) . '/';
if(preg_match($regexp, $v1, $matches))
{
$group = $matches[0];
}
else
{
# handle situation where it's not found to be any of those groups
}



Perfecto! Worked as advertised =D

Thanks guys, really appreciate it.