Sharapov,
Here's an example of the code I used to see if somebody belongs to a certain group. This is using PEAR's db_ldap2 extension .. I find it very handy. You can tell if somebody is part of a group very easy ... depending on your ActiveServer setup, you may not require an encrypted SSL link (for mine I did for authentication). If you do not require the SSL link, you can pass $user:$password@ (in front of the $server part of the DSN).
HTH
~Steve
PS -> Still haven't been able to detect the user logged in, I figure I'll get them to log on the first time, and set a cookie with the md5 encrypted version of their password. Each time they reach the page, check the password & user with the LDAP server. If it changes, require them to log on again.
<?php
// #################################
// (@Author): Stephen March
// (@Date): July 3, 2003
// (@Description): LDAP query to see if a user belongs to the IACB group
// ######################################
require_once 'DB.php';
// ---------------------------------------------------
// Values for the LDAP Connection & Query. Only
// modify these if you know what you are doing!
// ---------------------------------------------------
$server = "serverIP";
$base_dn = "ou=my_group,o=my_org";
$attrib_list = "";
$scope = "scope_one";
$filter = "cn=myname";
// ------[Create connection, and connect]=---------
$dsn = "ldap2://$server/$base_dn?$attrib_list?$scope";
$ldap = DB::connect($dsn);
// ------------------------------------------------
// Quick and dirty error handling, just fail if
// there's a problem, no need for an error message
// ------------------------------------------------
if (!DB::isError($ldap))
{
$result = $ldap->query($filter);
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
// ----------------------------------------
// Loop through each of the attributes
// ----------------------------------------
while(list($attribute,$value) = each($row))
{
switch($attribute)
{
case "dn":
$org = split(",", $value);
$branch = str_replace("ou=","",$org[1]);
break;
case "sn":
case "givenname":
$fullname .= $value . " ";
break;
}
$found=true;
}
}
$ldap->disconnect();
// ---------------------------------------------
// Display results, set cookies, whatever
// ---------------------------------------------
if(!$found)
echo "Sorry, user not found!";
else
echo "$fullname is a member of $branch<br/>";
?>