This forum is no longer active. Please post your questions to our new community site

Forums WAMPStack

Ldap with Wampstack

Subscribe to Ldap with Wampstack 6 post(s), 2 voice(s)

 
Avatar mmartins 3 post(s)

I’ve been trying to add Ldap to the wampstack.

Ive edited the php.ini to remove the comment from the line
extension=php_ldap.dll

Copied the ldap dll file from the ext folder into system32 folder AND into the php folder ( I found conflicting oppinions on where it should go, so i ended up testing both)

Restarted apache.

The phpinfo display doesnt show anything related to ldap, but I wasnt sure, so I added a php file with this code:
===

<?php

// Designate a few variables
$host = “ldap://ad.gilmore.com”;
$user = “”mailto:ad-web@ad.wjgilmore.com">ad-web@ad.wjgilmore.com";
$pswd = “secret”;
echo “

PING!

”;
$ad = ldap_connect($host)
or die( “Could not connect!” );
echo “

PING!

”;
// Set version number
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3)
or die (“Could not set ldap protocol”);

// Binding to ldap server
$bd = ldap_bind($ad, $user, $pswd)
or die (“Could not bind”);

// Create the DN
$dn = “OU=People,OU=staff,DN=ad,DN=wjgilmore,DN=com”;

// Specify only those parameters we’re interested in displaying
$attrs = array(“displayname”,“mail”,“telephonenumber”);

// Create the filter from the search parameters
$filter = $POST[‘filter’].“=”.$POST[‘keyword’].“*”;

echo “

PING!!

”;

$search = ldap_search($ad, $dn, $filter, $attrs)
or die (“ldap search failed”);

$entries = ldap_get_entries($ad, $search);
$zero=0;

echo “

PING!!!

”;

if(($entries[“count”]>$zero))
{
for ($i=0; $i<$entries[“count”]; $i++) {
echo "

Name: “.$entries[$i][”displayname"]0.“
”;
echo "Phone: “.$entries[$i][”telephonenumber"]0.“
”;
echo "Email: “.$entries[$i][”mail"]0.“

”;
}

} else {
echo “

No results found!

”;
}

ldap_unbind($ad);

?>
===

I crashes whenever any function from ldap is invoked ( showing only the first ping message) , what am I doing wrong?

I tried to post this before but I missposted on the wrong area.
Thanks for the attention.

 
Avatar Beltrán Rueda Administrator 3,714 post(s)

Hi,

Could you try this example?


    <?php
    $ldap = ldap_connect(“domain.com”);
    $username=<a href="mailto:”username@domain.com">”username@domain.com</a>”;
    $password=”password”;
    if($bind = ldap_bind($ldap, $username,$password ))
    echo “logged in”;
    else
    echo “fail”;
    echo “<br/>done”;
    ?>
 
Avatar mmartins 3 post(s)

========
Server error.

The website encountered an error while retrieving http://localhost/xbx6/testeld.php. It may be down for maintenance or configured incorrectly.

Here are some suggestions:
Reload this web page later.
More information on this error
Below is the original error message

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
=====

This happens when I test that code.

 
Avatar Beltrán Rueda Administrator 3,714 post(s)

Hi,

We noticed that it is required that libeay32.dll and ssleay32.dll libraries are in the PATH http://php.net/manual/en/ldap.installation.php

Copy and overwrite these libraries from php/ folder to apache2/bin folder and try to connect now.

 
Avatar mmartins 3 post(s)

Overwrote the files on the Bin directory as per intructions, restarted apache.

The same bevhaviour as observed so far persists.

 
Avatar Beltrán Rueda Administrator 3,714 post(s)

Sorry not sure what the problem is.

Forums WAMPStack