I have an LDAP database (windows 03 AD) and using php 5.2 to access the database. the problem I am having is getting the member of array to loop and then decide if they are part of the group that is authorized to view the page... below is what i have done so far.
<?
/******globals needed for included pages***/
global $displayname;
global $company;
$user =& JFactory::getUser();
/*************Ens of globals needed for included pages***/
$dn = "OU=Coleman-users,DC=coleman-home,DC=com";
$attributes = array("displayname","memberof","1");
$filter = "(cn=" .$user->name.")";
$ad = ldap_connect("server02.coleman-home.com")
or die("Couldn't connect to AD!");
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
$bd = ldap_bind($ad,"administrator@coleman-home.com","****")
or die("Couldn't bind to AD!");
$result = ldap_search($ad, $dn, $filter, $attributes);
$entries = ldap_get_entries($ad, $result);
$i=0;
while($i < 5 ){
$displayname=$entries[0]["displayname"][0];
$member[$i]=$entries[0]["memberof"][$i];
//echo $member[$i];
$i++;
if($member[$i]=="CN=WSS_ADMIN_WPG,CN=Users,DC=coleman-home,DC=com"){
echo "You are authorized to see this" . $displayname. "<br><br>";
//echo $member ."<br>";
exit;
}
else{
echo "you are not authorized";
}
}
//$company=$entries[0]["company"][0];
//echo $member .
"<br />";
//echo $entries[0]["company"][0].
"<br />";
//}
ldap_unbind($ad);
?>
I am able to connect and get the data, so i guess this is more of a php question that anything else.
Thanks
MCP ACA-I CTP
<?
/******globals needed for included pages***/
global $displayname;
global $company;
$user =& JFactory::getUser();
/*************Ens of globals needed for included pages***/
$dn = "OU=Coleman-users,DC=coleman-home,DC=com";
$attributes = array("displayname","memberof","1");
$filter = "(cn=" .$user->name.")";
$ad = ldap_connect("server02.coleman-home.com")
or die("Couldn't connect to AD!");
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
$bd = ldap_bind($ad,"administrator@coleman-home.com","****")
or die("Couldn't bind to AD!");
$result = ldap_search($ad, $dn, $filter, $attributes);
$entries = ldap_get_entries($ad, $result);
$i=0;
while($i < 5 ){
$displayname=$entries[0]["displayname"][0];
$member[$i]=$entries[0]["memberof"][$i];
//echo $member[$i];
$i++;
if($member[$i]=="CN=WSS_ADMIN_WPG,CN=Users,DC=coleman-home,DC=com"){
echo "You are authorized to see this" . $displayname. "<br><br>";
//echo $member ."<br>";
exit;
}
else{
echo "you are not authorized";
}
}
//$company=$entries[0]["company"][0];
//echo $member .
"<br />";
//echo $entries[0]["company"][0].
"<br />";
//}
ldap_unbind($ad);
?>
I am able to connect and get the data, so i guess this is more of a php question that anything else.
Thanks
MCP ACA-I CTP