【发布时间】:2011-03-29 10:15:47
【问题描述】:
我想运行这个功能,或者至少是使用不同凭据从 AD 中删除机器帐户的位:
public static void DeleteMachineAccount(String MachineName)
{
String MachineLdapPath = LdapPath(MachineName);
String OuLdapPath = MachineLdapPath.Replace("CN=" + MachineName + ",", "");
Console.WriteLine(MachineLdapPath);
Console.WriteLine(OuLdapPath);
if (DirectoryEntry.Exists(MachineLdapPath))
{
try
{
DirectoryEntry MachineOu = new DirectoryEntry(OuLdapPath);
DirectoryEntry MachineToDelete = new DirectoryEntry(MachineLdapPath);
MachineOu.Children.Remove(MachineToDelete);
MachineToDelete.CommitChanges();
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
}
}
(LdapPath 函数只返回指定机器名称的 LDAP 路径。)
我如何/在哪里指定一些不同的凭据以允许它运行?目前我被拒绝访问,因为我使用的帐户无权执行此操作。
谢谢,
本
【问题讨论】:
标签: c# permissions active-directory