|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30819 Patch to properly support LDAP SASL binds
Submitted: 2004-11-18 00:16 UTC Modified: 2005-09-06 18:09 UTC
Avg. Score:5.0 ± 0.0
Reproduced:10 of 10 (100.0%)
Same Version:9 (90.0%)
Same OS:8 (80.0%)
From: quanah at stanford dot edu Assigned:
Status: Closed Package: LDAP related
PHP Version: 5CVS-2005-02-21 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: quanah at stanford dot edu
New email:
PHP Version: OS:


 [2004-11-18 00:16 UTC] quanah at stanford dot edu

I've written a patch against PHP-5.0.2 that properly impelments LDAP SASL binds for all mechanisms.  The current code in 5.0.2 does not support LDAP SASL binds at all, although the function exists.

The patch can be found at:

It follows the PHP development guidelines.

This patch has been tested with multiple SASL authentication mechanisms.


Reproduce code:
$ldap = ldap_connect("");
if($ldap) {
   $r = ldap_bind($ldap);
} else {
  echo "Unable to connect!";


if (ldap_sasl_bind($ldap,"","","GSSAPI"))
    $dn = "cn=people,dc=stanford,dc=edu";
    $filter = "(|(susearchid=$WEBAUTH_USER)(mail=$WEBAUTH_USER@*))";
    $result = ldap_search($ldap, $dn, $filter);
    if ($result)
       echo "Number of entries returned is " . ldap_count_entries($ldap, $result) . "<br />";
       $info = ldap_get_entries($ldap,$result);
       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]["cn"][0] . "<br />";
           echo "first email is: " . $info[$i]["mail"][0] . "<br /> <hr />";

Expected result:
I'd expect this to work in PHP

Actual result:
Doesn't work at all without my patch.

Works correctly with my patch.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-18 00:50 UTC] dhawes at vt dot edu
I attempted to get a similar patch submitted last May, but discussion came to a standstill.  Quanah and I have tested this with GSSAPI, EXTERNAL, and (I believe) DIGEST-MD5.  I would like to see this patch included in PHP so I can stop requiring users to patch their source.
 [2005-04-11 01:52 UTC]
Please try this modified patch:

I added some convenience constants and made all the 
parameters optional (except for the 1st one).

I tried it with your script here but it didn't work for me.

 [2005-04-17 18:26 UTC]
My patch is now committed to CVS.

 [2005-04-26 23:22 UTC] quanah at stanford dot edu
Tested this patch, and it worked fine for me.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 00:01:31 2024 UTC