首页 新闻 会员 周边 捐助

大神们,请进啊,C# AD域 删除域组织单位,报 目录服务只可以在一个页状对象上运行

0
[待解决问题]

DirectoryEntry domian = null;
IsConnected("dachkj.com", "liubq", "abcd1234!", out domian);
if (domian != null)
{

DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = domian;
deSearch.Filter = "(&(objectClass=organizationalUnit)(OU=技术部))";
SearchResultCollection results = deSearch.FindAll();
if (results.Count > 0)
{
DirectoryEntry parentOuEntry = results[0].GetDirectoryEntry();


DirectoryEntries dentrys = parentOuEntry.Children;
DirectoryEntry organizeEntry = dentrys.Find("OU=技术小组", "organizationalUnit");
dentrys.Remove(organizeEntry);
organizeEntry.CommitChanges();

//ouEntry.UsePropertyCache = true;
//ouEntry.Rename("OU=技术小组1");
//DirectoryEntry OU = ouEntry.Children.Add("OU=技术小组", "organizationalUnit");
//OU.CommitChanges();
//ouEntry.CommitChanges();
}
}

在执行Remove抛异常,里面所用到的对象都能正常获取,很奇怪,求大神指点迷津!

zhangsani的主页 zhangsani | 初学一级 | 园豆:6
提问于:2016-12-14 11:05
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册