Bonjour a tous
je suis pas sur d'etre au bon endroit..je tente:
Je souhaite me connecter a un active directory depuis un LINUX via un script PHP, recuperer des données et les formatter en XML.

J'ai fouiner un peu et j'ai creer un script qui a l'air de marcher mais j'ai aucun resultat. Voici de script:

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
<?php
 
// specify the LDAP server to connect to
$conn = ldap_connect("localhost") or die("Could not connect to server");
 
// bind to the LDAP server specified above
$r = ldap_bind($conn) or die("Could not bind to server");
 
// start searching
// specify both the start location and the search criteria
// in this case, start at the top and return all entries
$result =ldap_search($conn,"dc=domaine,dc=com", "(sn=*)")
or die ("Error in searchquery");
 
$info = ldap_get_entries($conn, $result);
// iterate over array and print data for each entry
for ($i=0; $i<$info["count"]; $i++)
{
    echo "dn is: ". $info[$i]["dn"] ."<br>";
    echo "first cn is: ". $info[$i]["cn"][0] ."<br>";
    echo "first email address is: ". $info[$i]["mail"][0] ."<p>"; }
 
// print number of entries found
echo "Number of entries found: " . ldap_count_entries($conn, $result) .
"<p>";
 
// all done? clean up
ldap_close($conn);
?>

j'ai les parametre localhost et domaine...
Ensuite j'ai ceci comme fichier de config, la on voit le nom des champs:

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
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<appSettings>
		<add key="ConnectionString" value="Server=XXXX; Database=SAGA;User ID=XXXXX;Password=XXXXX;timeout=30;" />
		<add key="LDAP_Path" value="LDAP://DC=garrigues,DC=com" />
		<add key="SMTP_Server" value="ESMADEX306.garrigues.com" />
		<add key="SMTP_Destination" value="xxxxxxxxx" />
		<add key="ReportExceptionsToOperator" value="False" />
		<!-- Claves para los propiedades de AD del Empleado -->
		<add key="AD_EmployeeID" value="extensionattribute15" />
		<add key="AD_DomainUser" value="samaccountname" />
		<add key="AD_EmployeeName" value="name" />
		<add key="AD_EMail" value="mail" />
		<add key="AD_IdSociedad" value="extensionattribute1" />
		<add key="AD_IdDepartamento" value="extensionattribute8" />
		<add key="AD_IdOficina" value="physicaldeliveryofficename" />
		<add key="AD_Area" value="AD_Areae" />
		<add key="AD_Categoria" value="extensionattribute4" />
	</appSettings>
</configuration>
Lorsque je l'execute en ligne de commande: php -a toto.php
ca me renvoie que y'a 0 resultats...
Alors ma question est: le filtre de recherche est il bien?
j'ai ceci: "(sn=*) mais je sais pas du tout si c'est le bon parametre...
Un peu d'aide?
Merci