ASP C# et Active directory .. probleme rien ne s'affiche mais aucune erreur
bonjour,
pour précisez je suis novice en ASP C#.
En faite j'sai de me connecter à mon active directory juste pour afficher les information d'un utilisateur.
Le probleme est que rien ne s'affiche .. et je n'est aucune erreur lors de la génération du site ... :?
J'utilise un Server 2003 avec ISS 6.0
Voici mes trois fichier :
fichier Default.aspx
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
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Page sans titre</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
try
{
System.DirectoryServices.DirectoryEntry Ldap = new System.DirectoryServices.DirectoryEntry("LDAP://ASPHP-AD/", "Administrateur", "toto");
System.DirectoryServices.DirectorySearcher searcher = new System.DirectoryServices.DirectorySearcher(Ldap);
searcher.Filter = "(objectClass=Administrateur)";
foreach (System.DirectoryServices.SearchResult result in searcher.FindAll())
{
System.DirectoryServices.DirectoryEntry DirEntry = result.GetDirectoryEntry();
Console.WriteLine("Login : " + DirEntry.Properties["SAMAccountName"].Value);
Console.WriteLine("Nom : " + DirEntry.Properties["sn"].Value);
Console.WriteLine("Prénom : " + DirEntry.Properties["givenName"].Value);
Console.WriteLine("Email : " + DirEntry.Properties["mail"].Value);
Console.WriteLine("Tél : " + DirEntry.Properties["TelephoneNumber"].Value);
Console.WriteLine("Description : " + DirEntry.Properties["description"].Value);
Console.WriteLine("-------------------");
}
}
catch(Exception Ex)
{
Console.WriteLine(Ex.Message);
}
%>
</div>
</form>
</body>
</html> |
Fichier Default.aspx.cs
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
using System;
using System.Data;
using System.Configuration;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
} |
Fichier Web.Config
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
</system.web>
</configuration> |
Si quelqu'un a une idée
Cordialement,
Fas3r