public ActionResult AddOUDept(string parentDeptName, string deptName) { string filePath = Server.MapPath("~/ADConfig.xml"); AdOperate ado = new AdOperate(filePath); DirectoryEntry entry = ado.GetEntry(); string filter = "(&(objectclass=organizationalUnit)(ou=" + parentDeptName + "))"; DirectoryEntry ouEntry = ado.GetOUEntry(entry, filter); if (!ado.AddOUEntry(ouEntry, deptName)) { return(Json(new AjaxResult { Status = "error", Msg = "ad域中添加部门失败" })); } RtxDeptManager rdm = new RtxDeptManager(); if (!rdm.AddDept(deptName, parentDeptName)) { filter = "(&(objectclass=organizationalUnit)(ou=" + deptName + "))"; ado.DelEntry(ado.GetOUEntry(entry, filter)); return(Json(new AjaxResult { Status = "error", Msg = "RTX中添加部门失败" })); } return(Json(new AjaxResult { Status = "ok", Msg = "部门同步添加成功" })); }
public ActionResult DelUser(string userName) { string filePath = Server.MapPath("~/ADConfig.xml"); AdOperate ado = new AdOperate(filePath); DirectoryEntry entry = ado.GetEntry(); DirectoryEntry userEntry = ado.GetUserEntry(entry, userName); ado.DelEntry(userEntry); RtxUserManager rum = new RtxUserManager(); rum.RemoveUser(userName); return(Json(new AjaxResult { Status = "ok", Msg = "用户删除成功" })); }
public ActionResult DelOUDept(string deptName) { 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); ado.DelEntry(ouEntry); RtxDeptManager rdm = new RtxDeptManager(); rdm.DelDept(deptName); return(Json(new AjaxResult { Status = "ok", Msg = "部门删除成功" })); }