ldap_bind

(PHP 3, PHP 4, PHP 5)

ldap_bind -- LDAP ディレクトリにバインドする

説明

bool ldap_bind ( resource link_identifier [, string bind_rdn [, string bind_password]] )

指定した RDN およびパスワードを用いて LDAP ディレクトリをバインドします。 成功の場合に TRUE、エラーの場合に FALSE を返します。

ldap_bind() は、ディレクトリに関するバインド動作を 行います、bind_rdn および bind_password はオプションです。 指定されない場合は、匿名(anonymous) バインドが試みられます。

例 1. LDAP バインドの使用

<?php

// ldap バインドを使用する
$ldaprdn  = 'uname';     // ldap rdn あるいは dn
$ldappass = 'password';  // パスワード

// ldap サーバに接続する
$ldapconn = ldap_connect("ldap.example.com")
    or die(
"Could not connect to LDAP server.");

if (
$ldapconn) {

    
// ldap サーバにバインドする
    
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

    
// バインド結果を検証する
    
if ($ldapbind) {
        echo
"LDAP bind successful...";
    } else {
        echo
"LDAP bind failed...";
    }
        
}

?>

例 2. LDAP 匿名バインドの使用

<?php

// ldap 匿名バインドを使用する

// ldap サーバに接続する
$ldapconn = ldap_connect("ldap.example.com")
    or die(
"Could not connect to LDAP server.");

if (
$ldapconn) {

    
// 匿名でバインドする
    
$ldapbind = ldap_bind($ldapconn);

    if (
$ldapbind) {
        echo
"LDAP bind anonymous successful...";
    } else {
        echo
"LDAP bind anonymous failed...";
    }

}
    
?>