LDAP 函数
在线手册:中文 英文
PHP手册

ldap_sasl_bind

(PHP 5)

ldap_sasl_bindBind to LDAP directory using SASL

说明

bool ldap_sasl_bind ( resource $link [, string $binddn = NULL [, string $password = NULL [, string $sasl_mech = NULL [, string $sasl_realm = NULL [, string $sasl_authc_id = NULL [, string $sasl_authz_id = NULL [, string $props = NULL ]]]]]]] )
Warning

本函数还未编写文档,仅有参数列表。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE.

注释

Note: Requirement
ldap_sasl_bind() requires SASL support (sasl.h). Be sure --with-ldap-sasl is used when configuring PHP otherwise this function will be undefined.

更新日志

版本 说明
5.3.3 Support on Windows was added.


LDAP 函数
在线手册:中文 英文
PHP手册
PHP手册 - N: Bind to LDAP directory using SASL

用户评论:

Caleb Callaway (06-Aug-2011 05:18)

Code snippet demonstrating how to establish a TLS-encrypted connection to an OpenLDAP server from an Apache webserver and authenticate using a user's Kerberos credentials. Credentials MUST be delegated to the web server for this method to work.

<?php

putenv
("KRB5CCNAME={$_SERVER['KRB5CCNAME']}");

$resource = ldap_connect("ldap.example.com")
    or die(
"Failed to connect to LDAP server.");

echo
"Connected to LDAP server.<br />";

//these options may not be necessary in all environments
ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3);   
ldap_set_option($resource, LDAP_OPT_REFERRALS, 0);
   
$result = ldap_start_tls($resource)
    or die(
"Failed to start TLS");

echo
"Started TLS.<br />";

$result = ldap_sasl_bind($resource, NULL, '', 'GSSAPI', 'EXAMPLE.COM', '', '')
    or die(
"Failed to GSSAPI bind.<br />");

echo
"GSSAPI bound.";
  
?>

dwhite at olp dot net (23-Sep-2007 01:30)

With the patch introduced in the bug below (which has been included in CVS), the parameters for this function should be:

bool ldap_sasl_bind ( resource $link [, string $binddn [, string $password [, string $sasl_mech [, string $sasl_realm [, string $sasl_authc_id [, string $sasl_authz_id [, string $props]]]]]]] )

Some example calls:

$r=ldap_sasl_bind ( $ds, NULL, 'mysecret', 'DIGEST-MD5', NULL, 'jimmy');

With authz_id, specifying a dn:
$r=ldap_sasl_bind ( $ds, NULL, 'mysecret', 'DIGEST-MD5', NULL, 'jimmy', 'dn:uid=tommy,ou=people,dc=example,dc=com');

With authz_id, specifying a SASL username:
$r=ldap_sasl_bind ( $ds, NULL, 'mysecret', 'DIGEST-MD5', NULL, 'jimmy', 'u:tommy');

Also, since SASL authentication was introduced in LDAP version 3,
you may need to explicitly set the version number with:
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

dahgdevash at gmail dot com (26-May-2007 06:44)

Bug , the function parameters are sent incorrectly to the server
Look at:
http://bugs.php.net/bug.php?id=39291