7.47 LDAP
7 Index des fonctions
Manuel PHP
. Introduction . Pré-requis . Installation . Configuration à l'exécution . Types de ressources . Constantes prédefinies . Exemples . Utiliser les fonctions LDAP de PHP . ldap_8859_to_t61 . ldap_add ->ldap_bind . ldap_close . ldap_compare . ldap_connect . ldap_count_entries . ldap_delete . ldap_dn2ufn . ldap_err2str . ldap_errno . ldap_error . ldap_explode_dn . ldap_first_attribute . ldap_first_entry . ldap_first_reference . ldap_free_result . ldap_get_attributes . ldap_get_dn . ldap_get_entries . ldap_get_option . ldap_get_values_len . ldap_get_values . ldap_list . ldap_mod_add . ldap_mod_del . ldap_mod_replace . ldap_modify . ldap_next_attribute . ldap_next_entry . ldap_next_reference . ldap_parse_reference . ldap_parse_result . ldap_read . ldap_rename . ldap_search . ldap_set_option . ldap_set_rebind_proc . ldap_sort . ldap_start_tls . ldap_t61_to_8859 . ldap_unbind
|
7.47.11 ldap_bind()Autentification au serveur LDAP[ Exemples avec ldap_bind ] PHP 3, PHP 4
bool
ldap_bind (
resource
link_identifier
,
string
bind_rdn
,
string
bind_password
)
ldap_bind
s'autentifie auprès du serveur
LDAP
link_identifier
, avec le nom d'utilisateur
bind_rdn
et le mot de passe
bind_password
. Cette fonction retourne
TRUE
en cas de succès,
FALSE
en cas d'échec.
ldap_bind
effecute une opération de bind
avec le serveur.
bind_rdn
et
bind_password
sont optionnels. S'ils
sont omis, une tentative de connexion anonyme est tentée.
Identification avec LDAP |
<?php
// Eléments d'identification LDAP $ldaprdn = 'nom d\'utilisateur'; // DN ou RDN LDAP $ldappass = 'mot de passe'; // 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);
// Identification if ($ldapbind) { echo "Connexion LDAP réussie"; } else { echo "Connexion LDAP échouée"; } }
?>
|
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) {
// identification anonyme $ldapbind = ldap_bind($ldapconn);
if ($ldapbind) { echo "Connexion LDAP anonmye réussie"; } else { echo "Connexion LDAP anonmye échouée"; } } ?>
|
|