php.net |  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
Votes:10
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
40 - 3 = ?
Subscribe to this entry?

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

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:

http://www.stanford.edu/services/directory/clients/examples/ldap-sasl

It follows the PHP development guidelines.

This patch has been tested with multiple SASL authentication mechanisms.

Regards,
Quanah

Reproduce code:
---------------
#!/usr/local/bin/php
<?php
$ldap = ldap_connect("ldap.stanford.edu");
if($ldap) {
   $r = ldap_bind($ldap);
} else {
  echo "Unable to connect!";
}

ldap_set_option($ldap,LDAP_OPT_PROTOCOL_VERSION,3);

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 />";
       print("\n");
       $info = ldap_get_entries($ldap,$result);
       echo "Data for " . $info["count"] . " items returned:<p>";
       print("\n");
       
       for($i=0;$i<$info["count"];$i++) {
           echo "dn is: " . $info[$i]["dn"] . "<br />";
           print("\n");
           echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />";
           print("\n");
           echo "first email is: " . $info[$i]["mail"][0] . "<br /> <hr />";
           print("\n");
       }
    }
       
ldap_close($ldap);
}
?>

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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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] sniper@php.net
Please try this modified patch:
 
  http://www.php.net/~jani/patches/bug30819.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] sniper@php.net
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.

--Quanah
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 04:01:28 2024 UTC