Active directory et création de compte
Bonjour à tous,
voila je cherche depuis ce matin à ajouter un utilisateur dans l'AD sauf que je suis confronté à un problème, à chaque fois que j'exécute ma méthode, je récupère une exception :
Citation:
Cet objet ne se trouve pas sur le serveur. (Exception de HRESULT : 0x80072030)
Voici le code associé,
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public static User Add(User user, String organisation, String unit)
{
user.Path = ADPaths.GetUserPath(user.Login, organisation, unit);
using (DirectoryEntry entry = new DirectoryEntry(ADPaths.GetUserPath(organisation, unit), AppSettings.ADLogin, AppSettings.ADPasswd))
{
using (DirectoryEntry userEntry = entry.Children.Add(user.Path, ADClasses.USER))
{
userEntry.Properties[ADAttributes.SAMACCOUNTNAME].Add(user.Login);
userEntry.CommitChanges();
userEntry.RefreshCache();
}
}
return user;
} |
je vous remercie d'avance pour l'aide.