Jump to content

LDAPS failing 9/10 times


daq

Recommended Posts

I need to authenticate over LDAP server, but I also need the info transfered to be encrypted. I got it working over LDAP, and then I just changed the address to ldaps and now authentication fails 9/10 times. Any ideas? It does occasionally work which is really strange!

 

Any suggestions are welcome! Thanks.

 

I'm using a basic script to test connection to ldap server:

<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection

echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
$ds=ldap_connect("ldaps://myserver.com");  // must be a valid LDAP server!
echo "connect result is " . $ds . "<br />";

$username = "test";
if ($ds) {
    echo "Binding ...";
    $r=ldap_bind($ds);     // this is an "anonymous" bind, typically
                           // read-only access
    echo "Bind result is " . $r . "<br />";

    echo "Searching for (sn=$username) ...";
    // Search surname entry
    $sr=ldap_search($ds, "o=test", "userid=$username");
    echo "Search result is " . $sr . "<br />";

    echo "Number of entires returned is " . ldap_count_entries($ds, $sr) . "<br />";

    echo "Getting entries ...<p>";
    $info = ldap_get_entries($ds, $sr);
    echo "Data for " . $info["count"] . " items returned:<p>";

    for ($i=0; $i<$info["count"]; $i++) {
        echo "dn is: " . $info[$i]["dn"] . "<br />";
        echo "first cn entry is: " . $info[$i]["givenName"][0] . "<br />";
        echo "first email entry is: " . $info[$i]["mail"][0] . "<br /><hr />";
    }

    echo "Closing connection";
    ldap_close($ds);

} else {
    echo "<h4>Unable to connect to LDAP server</h4>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/49532-ldaps-failing-910-times/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.