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 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 = "部门同步编辑成功" })); }
public ActionResult EditRtx(string deptName) { RtxDeptManager dept = new RtxDeptManager(); dept.RemoveDept(deptName); return(Json(new AjaxResult { Status = "ok", Msg = "success" })); }
public ActionResult DelDept(string deptName) { RtxDeptManager rdm = new RtxDeptManager(); if (rdm.DelDept(deptName)) { return(Json(new AjaxResult { Status = "ok", Msg = "删除成功", Data = deptName })); } return(Json(new AjaxResult { Status = "error", 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 = "部门删除成功" })); }
public ActionResult SyncRtx(string comName) { string filePath = Server.MapPath("~/ADConfig.xml"); AdOperate ado = new AdOperate(filePath); //ado.GetADConfig(filePath,comName); DirectoryEntry entry = ado.GetEntry(); RtxDeptManager dept = new RtxDeptManager(); RtxUserManager user = new RtxUserManager(); string filter = "objectclass=organizationalUnit"; ado.OUEntrySyncRtx(entry, filter, dept); filter = "(&(objectCategory=person)(objectClass=user))"; ado.UserEntrySyncRtx(entry, filter, user, dept); return(Json(new AjaxResult { Status = "ok", Msg = "success" })); }
static void Main6(string[] args) { string filePath = @" F:\1708\RtxLdap\TestCode\ADConfig.xml"; AdOperate ado = new AdOperate(filePath); DirectoryEntry entry = ado.GetEntry(); RtxDeptManager dept = new RtxDeptManager(); RtxUserManager user = new RtxUserManager(); string filter = "objectclass=organizationalUnit"; ado.OUEntrySyncRtx(entry, filter, dept); filter = "(&(objectCategory=person)(objectClass=user))"; ado.UserEntrySyncRtx(entry, filter, user, dept); //if(ado.CheckADUser(path,"leinuo","Asd654123")) //{ // Console.WriteLine("测试成功"); //} Console.WriteLine("测试成功"); Console.ReadKey(); }