Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks
Bibliothèques et frameworks Forum d'entraide sur les frameworks, templates, bibliothèques de code (PDFLib, eZPdf, JpGraph, Artichow, PEAR, etc). Avant de poster : FAQ bibliothèques, toutes les FAQ PHP et cours bibliothèques
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 29/01/2008, 15h18   #1
Membre habitué
 
Avatar de crashyear
 
Homme Alexis COLLIN
Ingénieur développement logiciels
Inscription : janvier 2006
Messages : 194
Détails du profil
Informations personnelles :
Nom : Homme Alexis COLLIN
Âge : 26
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : Santé

Informations forums :
Inscription : janvier 2006
Messages : 194
Points : 119
Points : 119
Envoyer un message via MSN à crashyear
Par défaut [LDAP] undefined function ldap_connect()

Bonjour,

Ce script ne fonctionne pas :
Code :
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?
crashyear est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/01/2008, 15h27   #2
Membre habitué
 
Avatar de crashyear
 
Homme Alexis COLLIN
Ingénieur développement logiciels
Inscription : janvier 2006
Messages : 194
Détails du profil
Informations personnelles :
Nom : Homme Alexis COLLIN
Âge : 26
Localisation : France

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : Santé

Informations forums :
Inscription : janvier 2006
Messages : 194
Points : 119
Points : 119
Envoyer un message via MSN à crashyear
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
crashyear est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 13h00.


 
 
 
 
Partenaires

Hébergement Web