Issue with ldap_bind() with blank user name and password
<p>First of all LDAP_bind anonymous is enabled. The problem that i am having is the following:</p>

<p>This code works fine without a problem:</p>

<pre><code>&lt;?php
$ldaprdn  = 'uname';   
$ldappass = 'password';  

$ldapconn = ldap_connect("ldap.example.com")
    or die("Could not connect to LDAP server.");

if ($ldapconn) {
    // binding to ldap server
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

    if ($ldapbind) {
        echo "LDAP bind successful...";
    } else {
        echo "LDAP bind failed...";
    }
}
?&gt;
</code></pre>

<p>This one below returns "success" no matter what</p>

<pre><code>   &lt;?php
    $ldaprdn  = '';   
    $ldappass = '';  

    $ldapconn = ldap_connect("ldap.example.com")
        or die("Could not connect to LDAP server.");

    if ($ldapconn) {
        // binding to ldap server
        $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

        if ($ldapbind) {
            echo "LDAP bind successful...";
        } else {
            echo "LDAP bind failed...";
        }
    }
    ?&gt;
</code></pre>

<p>Note that the credentials are left blank in this version. I do not like the fact that if the credentials are left blank that this thing goes and lets you in.  Am i doing something wrong? Or simply this ldap_bind() is convoluted. I would think that if i call the function with three parameters that it should not default to anonymous. </p>

<p>I can work around that by setting the username and password to dummy values in case the username and passwords are left blank but this is not good practice at all. 
Please Help...</p>

<p>source:http://php.net/manual/en/function.ldap-bind.php</p>
