예제 #1
0
        public ActionResult EditOUDept(string deptName, string newDeptName)
        {
            string         filePath = Server.MapPath("~/ADConfig.xml");
            AdOperate      ado      = new AdOperate(filePath);
            DirectoryEntry entry    = ado.GetEntry();
            string         filter   = "(&(objectclass=organizationalUnit)(ou=" + deptName + "))";
            DirectoryEntry ouEntry  = ado.GetOUEntry(entry, filter);

            if (!ado.OUEntryReName(ouEntry, newDeptName))
            {
                return(Json(new AjaxResult {
                    Status = "error", Msg = "ad域中编辑部门失败"
                }));
            }
            RtxDeptManager rdm = new RtxDeptManager();

            if (!rdm.SetDeptName(deptName, newDeptName))
            {
                filter = "(&(objectclass=organizationalUnit)(ou=" + newDeptName + "))";
                ado.OUEntryReName(ado.GetOUEntry(entry, filter), deptName);
                return(Json(new AjaxResult {
                    Status = "error", Msg = "RTX中编辑部门失败"
                }));
            }
            return(Json(new AjaxResult {
                Status = "ok", Msg = "部门同步编辑成功"
            }));
        }