PHP Conference Japan 2024

ldap_sasl_bind

(PHP 5, PHP 7, PHP 8)

ldap_sasl_bind使用 SASL 綁定到 LDAP 目錄

說明

ldap_sasl_bind(
    LDAP\Connection $ldap,
    ?字串 $dn = null,
    #[\SensitiveParameter] ?字串 $password = null,
    ?字串 $mech = null,
    ?字串 $realm = null,
    ?字串 $authc_id = null,
    ?字串 $authz_id = null,
    ?字串 $props = null
): 布林值
警告

此函式目前沒有說明文件;僅提供其參數列表。

返回值

成功時返回 true,失敗時返回 false

更新日誌

版本 說明
8.1.0 ldap 參數現在需要一個 LDAP\Connection 實例;先前需要一個有效的 ldap link 資源
8.0.0 dnpasswordmechrealmauthc_idauthz_idprops 現在可以為 null。

注意事項

注意需求
ldap_sasl_bind() 需要 SASL 支援 (sasl.h)。 否則,請確保在配置 PHP 時使用 --with-ldap-sasl,否則此函式將未定義。

新增註釋

使用者提供的註釋 4 則註釋

mbaynton
10 年前
在您的環境中除錯綁定失敗的提示:PHP 從此方法發出的許多警告以「PHP 警告:ldap_sasl_bind():無法綁定到伺服器:[原因]」開頭,其中 [原因] 可以是各種字串。這使得看起來像是 ldap_sasl_bind 造成的失敗,但所有 [原因] 實際上都來自底層 c 函式 ldap_sasl_interactive_bind_s。 除了 php 之外,許多軟體都使用該函式,因此我透過在網路上搜尋「ldap_sasl_interactive_bind_s [原因]」找到了更多故障排除資訊。
devel at romanr dot info
12 年前
存在一些可重入性錯誤:您無法在單個進程中多次使用此函式。 應該重新啟動 PHP 進程(apache 或 fastcgi)。 考慮 PHP_FCGI_MAX_REQUESTS=1
dwhite at olp dot net
17 年前
使用下面錯誤中引入的補丁(已包含在 CVS 中),此函式的參數應為

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]]]]]]] )

一些範例呼叫

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

使用 authz_id,指定 dn
$r = ldap_sasl_bind($ds, NULL, 'mysecret', 'DIGEST-MD5', NULL, 'jimmy', 'dn:uid=tommy,ou=people,dc=example,dc=com');

使用 authz_id 指定 SASL 使用者名稱
$r = ldap_sasl_bind($ds, NULL, 'mysecret', 'DIGEST-MD5', NULL, 'jimmy', 'u:tommy');

此外,由於 SASL 驗證是在 LDAP 版本 3 中引入的,
您可能需要使用以下指令明確設定版本號碼
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
dahgdevash at gmail dot com
17 年前
錯誤,函式參數傳送至伺服器的方式不正確
請參考
http://bugs.php.net/bug.php?id=39291
To Top