IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques et frameworks PHP Discussion :

[LDAP] undefined function ldap_connect()


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre habitué Avatar de crashyear
    Homme Profil pro
    Responsable d’exploitation informatique
    Inscrit en
    Janvier 2006
    Messages
    267
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Responsable d’exploitation informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2006
    Messages : 267
    Points : 176
    Points
    176
    Par défaut [LDAP] undefined function ldap_connect()
    Bonjour,

    Ce script ne fonctionne pas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
     
    <html>
    <?php
    include ("HEADER/header.php");
    ?>
    <body>
    Test de récupération des adresses e-mails sous forme de liste (avec ldap) :<br /><br />
    <?php
    //connection au serveur ldap
    $serveur="mon_serveur";
    $ds = ldap_connect($serveur);
    if($ds)
    { 
    	?>
    	<select name='mail' size='1'>
    	<option selected value='-1'> -- Sélectionner ici -- </option>
    	<?php
    	//echo "<br />Connected successfully !<br />";
    	//Authentification au serveur LDAP 
    	$result=ldap_bind($ds,$_POST['user'], $_POST['pass']);
    	if($result)
    	{ 
    		//echo "<br />Bind successful !<br />";		
     
    		//Search LDAP
    		$dn="...";
    		$filtre="cn=*";		
    		$sr = ldap_search($ds, $dn, $filtre); 
    		// Put the returned data into an array 
    		$info = ldap_get_entries($ds, $sr); 
    		//echo $info['count']." enregistrements trouvés<br />";
     
    		$cpt=0;
    		for($i = 0; $i < $info['count']; $i++) 
    		{
    			if($info[$i]['mail'][0]!='')
    			{
    				$tabmail[$cpt]=mb_strtolower($info[$i]['mail'][0]); //tableau [ compteur ] [ nom du champ ]
    				$cpt++;
    			}
    		}
    		sort($tabmail);
    		//echo count($tabmail);
    		for($i=0;$i<count($tabmail);$i++)
    		{
    			echo "<option value=".$tabmail[$i].">".$tabmail[$i]."</option>";
    		}
    	} 
    	else 
    	{
    		echo "<br />Error binding.<br />";
    	} 
    	ldap_close($ds);
    	echo '</select>';
    } 
    else 
    {
    	echo "<br />Error connecting .<br />";
    } 
     
    ?>
     
    </body>
    </html>
    Ce code me permet de lister les adresses mails de tout le monde.

    Mais j'ai cette erreur qui survient :
    Fatal error: Call to undefined function ldap_connect()

    J'ai verifié mon php.ini, l'extension php_ldap.dll est chargée.
    J'ai verifié le chemin vers mon repertoire d'extension php c'est ok.

    y'a quelqu'un qui peut m'aider?
    -> N'oubliez pas de mettre résolu
    http://collinalexis.free.fr

  2. #2
    Membre habitué Avatar de crashyear
    Homme Profil pro
    Responsable d’exploitation informatique
    Inscrit en
    Janvier 2006
    Messages
    267
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Responsable d’exploitation informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2006
    Messages : 267
    Points : 176
    Points
    176
    Par défaut Solution
    Désolé pour ce post,

    Je viens de trouver la solution à ce problème tout seul sur le web :

    Solved PHP LDAP error - Fatal error: Call to undefined function ldap_connect()
    After reading tens of articles and forum postings on the issue with error

    Fatal error: Call to undefined function ldap_connect()

    in Windows/PHP/Apache environment, I figured out why was this error appearing.

    Here is a checklist to make sure PHP-ldap functions work when called from Apache:

    1. In php.ini, enable setting extension_dir
    - find the line with this setting
    - remove the comment-indicating semicolon in front of its line
    - find your PHP extension directory (usually c:\php\ext)
    - set the setting to this directory
    - save php.ini
    - restart apache


    2. In php.ini, enable setting extension=php_ldap.dll
    - find the line with this setting
    - remove the comment-indicating semicolon in front of it
    - save php.ini
    - restart apache

    3. Run your script containing ldap_connect() call from command prompt:

    php myscript.php

    You should get either no error message, or error message related to another problem/function.

    4. Now - the part that solved my problem and is missing in all documents/postings on fixing the problem:
    - stop apache
    - make sure libeay32.dll and ssleay32.dll, used by Apache, are the latest ones, or at least the ones provided by the PHP installation in c:\php.
    If you have older versions of these DLLs somewhere in your system path (usually in c:\windows\system32)and for whatever compatibility or legacy reasons you don't want to update them, copy libeay32.dll and ssleay32.dll from c:\php to c:\Program Files\...\Apache\bin\
    - start apache


    http://www.incredium.com/php-ldap-connect-error
    -> N'oubliez pas de mettre résolu
    http://collinalexis.free.fr

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Fatal error: Call to undefined function ldap_connect()
    Par grandthor dans le forum Langage
    Réponses: 2
    Dernier message: 13/05/2011, 20h11
  2. Call to undefined function ldap_connect()
    Par diabli73 dans le forum Langage
    Réponses: 1
    Dernier message: 21/01/2011, 14h04
  3. Fatal error: Call to undefined function: ldap_connect()
    Par osnet dans le forum Bibliothèques et frameworks
    Réponses: 0
    Dernier message: 30/06/2010, 15h12
  4. Call to undefined function mysql_pconnect()
    Par shirya dans le forum Installation
    Réponses: 2
    Dernier message: 03/11/2005, 21h55
  5. undefined function: file_get_contents()
    Par camyo dans le forum Langage
    Réponses: 2
    Dernier message: 30/11/2004, 14h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo