Manuel PHP
ldap_bind
(PHP 4, PHP 5)
ldap_bind — Authentification au serveur LDAP
Description
bool ldap_bind
( resource $link_identifier
[, string $bind_rdn
[, string $bind_password
]] )
Authentification au serveur LDAP avec le RDN et le mot de passe spécifiés.
Liste de paramètres
- link_identifier
-
Un identifiant de lien LDAP, retourné par la fonction ldap_connect().
- bind_rdn
-
- bind_password
-
Si bind_rdn et bind_password ne sont pas spécifiés, un authentification anonyme est essayé.
Valeurs de retour
Cette fonction retourne TRUE en cas de succès, FALSE en cas d'échec.
Exemples
Exemple #1 Authentification avec LDAP
- <?php
- // Eléments d'authentification LDAP
- $ldaprdn = 'uname'; // DN ou RDN LDAP
- $ldappass = 'password'; // Mot de passe associé
- // Connexion au serveur LDAP
- $ldapconn = ldap_connect("ldap.example.com")
- or die("Impossible de se connecter au serveur LDAP.");
- if ($ldapconn) {
- // Connexion au serveur LDAP
- $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
- // Vérification de l'authentification
- if ($ldapbind) {
- echo "Connexion LDAP réussie...";
- } else {
- echo "Connexion LDAP échouée...";
- }
- }
- ?>
Exemple #2 Connexion anonyme à un serveur LDAP
- <?php
- // Connexion anonyme à un serveur LDAP
- // Connexion au serveur LDAP
- $ldapconn = ldap_connect("ldap.example.com")
- or die("Impossible de se connecter au serveur LDAP.");
- if ($ldapconn) {
- // Authentification anonyme
- $ldapbind = ldap_bind($ldapconn);
- if ($ldapbind) {
- echo "Connexion LDAP anonmye réussie...";
- } else {
- echo "Connexion LDAP anonmye échouée...";
- }
- }
- ?>
Remonter 
