Bonjour. J'ai un problème pour accéder à mon active directory à partir de ma page aspx.cs.
En fait, mon code est assez simple:
using System;
using System.DirectoryServices;
public partial class _test{
protected void Page_Load()
{
searchAndDestroy();
}
public void searchAndDestroy()
{
try
{
DirectoryEntry myEntry1;
DirectoryEntry myEntry2;
String strPath = "LDAP://172.1.1.2";
// Create a 'DirectoryEntry' object with the given path.
DirectoryEntry myDE = new DirectoryEntry(strPath);
DirectoryEntries myEntries = myDE.Children;
// Create a new entry in the container.
myEntry1 = myEntries.Add("CN=Sample Entry",myDE.SchemaClassName);
// Save changes in the 'Active Directory' store.
myEntry1.CommitChanges();
}
catch(Exception e)
{
Console.WriteLine("The following exception was raised : {0}",e.Message);
}
}
}
Mon problème est qu'il n'arrive pas à trouver la librairie on dirait, l'erreur de compilation est la suivante:
"The type or namespace name DirectoryService doesn't exist in namespace System (are U missing an assembly reference?)"
Je ne comprend vraiment pas pourquoi il ne la trouve pas. Je suis sûr de la syntaxe.
Par contre, petite précision, je teste ma page sur une machine virtuelle (je ne sais pas si ca peut etre du a ca..?)
Voila si quelqu'un a une idée, je lui en serai très reconnaisant (c'est pour mon stage).
Merci.