Quasipickle
Quasipickle

Reputation: 4498

How to see LDAP errors generated from PHP

I'm trying to bind to a remote, third party LDAP server. I can connect/bind/search just fine from the command line on my server, but PHP just gives the monumentally unhelpful error: "Cannot connect to server".

I've seen where I can set the log level, but I don't know where those errors actually get logged to. Searching along the lines of "ldap [client] log location" returns results exclusively for ldap servers

How do I see the errors PHP generates when trying to bind?

If it matters, I'm using Debian.

Edit

Here's the relevant code:

public function auth($username,$password){
    $ims_config = $this->di()->get('config')->ims;
    $username = $this->filterUsername($username);

    $this->conn = ldap_connect($ims_config->url);
    if($this->conn){
        $rdn = str_replace('?', $username, $ims_config->bind_rdn);

        if(ldap_bind($this->conn,$rdn,$password)){
            $this->isAuthed = TRUE;
        }
    }
    return $this->isAuthed;
}

I have checked $ims_config->url and $rdn, and they are correct.

Upvotes: 0

Views: 4180

Answers (1)

Bora
Bora

Reputation: 812

This is a pretty old question and the poster probably found the answer already, but for the sake of answering and completion, the PHP LDAP technote explains how you can do this using ldap_error($conn) and ldap_get_option($conn, LDAP_OPT_DIAGNOSTIC_MESSAGE, $err).

Upvotes: 2

Related Questions