php-windows Digest 16 Jul 2003 11:14:49 -0000 Issue 1825
Topics (messages 20801 through 20804):
Authenticating users on Active Directory using LDAP
20801 by: Igor Portnoy
Re: Newbie Q
20802 by: Heyz
20803 by: Heyz
20804 by: Gabriel_k
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hello,
I am running PHP on IIS5.0. I want users that come on the intranet to be
authenticated through the Active Directory. In other words, for example
if user that comes to the page belongs to a certain group in Active
Directory, he/she will see one page, but if user belongs to a different
group in Active Directory he/she will see a different page. I've read on
the Internet that it can be done with LDAP, but I wasn't able to find
any detailed information on how it can actually be done. I tried to do
it myself using LDAP functions described on the php.net, but I've hit
the wall. It looks like I am able to connect to the LDAP server and bind
it, but I can't seem to do any search on it. Below is the code that I
used. Can anybody help?
<?php
// specify the LDAP server to connect to
$conn = ldap_connect("192.XXX.XXX.XXX") or die("Could not connect to
server");
// bind to the LDAP server specified above
$r = ldap_bind($conn) or die("Could not bind to server");
// verify binding
if ($r) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
// start searching
// specify both the start location and the search criteria
// in this case, start at the top and return all entries
$base_dn = "DC=my_domain,DC=com";
$filter = "(cn=*)";
$result = ldap_search($conn, $base_dn, $filter) or die ("Error in search
query");
// get entry data as array
$info = ldap_get_entries($conn, $result);
// iterate over array and print data for each entry
for ($i=0; $i<$info["count"]; $i++)
{
echo "dn is: ". $info[$i]["dn"] ."<br>";
echo "first cn is: ". $info[$i]["cn"][0] ."<br>";
echo "first email address is: ". $info[$i]["mail"][0] ."<p>"; }
// print number of entries found
echo "Number of entries found: " . ldap_count_entries($conn, $result) .
"<p>";
// all done? clean up
ldap_close($conn);
?>
--- End Message ---
--- Begin Message ---
It's simple.
dirname(__FILE__);
"Gabriel_k" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How can I find out (as a string) in what dir my php script is run?
>
> /Gabbah
>
>
--- End Message ---
--- Begin Message ---
It's simple.
dirname(__FILE__)
"Gabriel_k" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How can I find out (as a string) in what dir my php script is run?
>
> /Gabbah
>
>
--- End Message ---
--- Begin Message ---
What if there is no file?
/Gabbah
"Heyz" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> It's simple.
>
> dirname(__FILE__)
>
>
> "Gabriel_k" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > How can I find out (as a string) in what dir my php script is run?
> >
> > /Gabbah
> >
> >
>
>
--- End Message ---