将用户添加到组A目录时,“服务器不愿意处理请求”

时间:2014-01-19 12:00:36

标签: c# active-directory ldap

我遇到的问题是一个AD而不会发生在另一个AD上(只是工作)

group.Invoke

的例外情况

代码:

root = new DirectoryEntry("ConfigurationManager.AppSettings["AD"], ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Password"]);

private void button3_Click(object sender, EventArgs e)
    {
        using (DirectorySearcher searcher = new DirectorySearcher(root))
        {
            searcher.Filter = "(&(objectcategory=group)(name=" + GroupName + "))";
            using (DirectoryEntry group = searcher.FindOne().GetDirectoryEntry())
            {
                searcher.Filter = "(&(SAMAccountName=" + PersonName + "))";
                using (DirectoryEntry user = searcher.FindOne().GetDirectoryEntry())
                {
                    group.Invoke("Add", user.Path);
                }
            }
        }
        RefreshList();
    }

这是否有原因?

编辑: Error

More details for error

0 个答案:

没有答案