public JsonResult Search()
        {
            //Log日志要记录的用户名
            string domain = Request.Form["domain"].Trim().ToString();

            string           searchkeyword = Request.Form["searchkeyword"].ToString();
            Groups           ad_group      = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO> col;

            if (searchkeyword.Trim() == "")
            {
                col = ad_group.SearchAllGroupsDTO(domain);
            }
            else
            {
                col = ad_group.SearchAllGroupsDTO(searchkeyword, domain);
            }


            string con = "<table id = \"example\" class=\"display\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>ID</th><th>Name</th><th>BelongsOUPath</th><th>Description</th><th>Exchange Modify</th></tr></thead><tbody>";

            for (int i = 0; i < col.Count; i++)
            {
                GroupsDTO gd = col.ElementAt(i);
                con += "<tr" + " " + "onclick=\"Group_detail(this)\"><td>" + i + "</td><td>" + gd.Name + "</td><td>" + gd.BelongsOUPath + "</td><td>" + gd.Description + "</td><td ><a type=\"button\" onclick=\"ExchangeEnabled(this)\" target=\"_blank\" class=\"btn btn - block\">Modify</a></td></tr>";//数据行,字段对应数据库查询字段
            }
            con += " </tbody></table>";

            return(Json(new JsonData(con)));
        }
        public JsonResult AuthorityManagement()
        {
            string Operator = "";

            if (Session["username"].ToString() != null)
            {
                Operator = Session["username"].ToString();
            }                                                                       //Log日志要记录的用户名
            string           domain         = Request.Form["domain"].Trim().ToString();
            string           searchcriteria = Request.Form["searchcriteria"].Trim().ToString();
            string           searchkeyword  = Request.Form["searchkeyword"].ToString();
            Groups           ad_group       = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO> col;

            if (searchkeyword.Trim() == "")
            {
                col = ad_group.SearchAllGroupsDTO(domain);
            }
            else
            {
                col = ad_group.SearchAllGroupsDTO(searchkeyword, domain);
            }


            string con = "<table id = \"example\" class=\"display\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>ID</th><th>Name</th></tr></thead><tbody>";

            for (int i = 0; i < col.Count; i++)
            {
                GroupsDTO gd = col.ElementAt(i);
                con += "<tr" + " " + "onclick=\"GetAuthorityCode(this)\"><td>" + i + "</td><td>" + gd.Name + "</td></tr>";//数据行,字段对应数据库查询字段
            }
            con += " </tbody></table>";
            return(Json(new JsonData(con)));
        }
        public JsonResult Delete()
        {
            string Operator = "";

            if (Session["username"].ToString() != null)
            {
                Operator = Session["username"].ToString();
            }                                                                       //Log日志要记录的用户名
            string groupname = Request.Form["groupname"].Trim().ToString();
            string domain    = Request.Form["domain"].Trim().ToString();

            Groups           ad_group = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO> col      = ad_group.SearchAllGroupsDTO(groupname, domain);

            GroupsDTO gd = col.ElementAt(0);

            string m;

            if (ad_group.DeleteUserGroupsDTO(gd))
            {
                m = "Delete Success";
                LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Delete%a%Group%named%" + groupname, true);
            }
            else
            {
                m = "Delete failed";
                LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Delete%a%Group%named%" + groupname, false);
            }
            return(Json(new JsonData(m)));
        }
        public JsonResult Details()
        {
            //Log日志要记录的用户名
            string           groupname = Request.Form["groupname"].Trim().ToString();
            string           domain    = Request.Form["domain"].Trim().ToString();
            Groups           ad_group  = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO> col       = ad_group.SearchAllGroupsDTO(groupname, domain);
            GroupsDTO        gd        = col.ElementAt(0);


            string con = "<table id = \"Memberof\" class=\"display\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>ID</th><th>GroupName</th></tr></thead><tbody>";

            for (int i = 0; i < gd.MembersOf.Count; i++)
            {
                string memberof = gd.MembersOf.ElementAt(i);

                con += "<tr><td>" + i + "</td><td>" + memberof + "</td></tr>";//数据行,字段对应数据库查询字段
            }
            con += " </tbody></table>";
            string members = "<table id = \"Mem\" class=\"display\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>ID</th><th>MembersName</th></tr></thead><tbody>";

            for (int i = 0; i < gd.Members.Count; i++)
            {
                string mem = gd.Members.ElementAt(i);

                members += "<tr><td>" + i + "</td><td>" + mem + "</td></tr>";//数据行,字段对应数据库查询字段
            }
            members += " </tbody></table>";
            groupdto gdt = new groupdto(gd, con, members);

            return(Json(gdt, JsonRequestBehavior.AllowGet));
        }
        }                                 //显示数据

        public JsonResult ExchangModfiy() //后台处理提交的数据并修改
        {
            string                       estr        = "";
            string                       userid      = Request.Form["userid"].Trim().ToString();
            string                       domain      = Request.Form["domain"].Trim().ToString();
            string                       DLShortname = Request.Form["DLShortname"].Trim().ToString();
            string                       GroupName   = Request.Form["GroupName"].Trim().ToString();
            string                       Emailname   = Request.Form["Emailname"].Trim().ToString();
            string                       RequireSenderAuthenticationEnabled = Request.Form["RequireSenderAuthenticationEnabled"].Trim().ToString();
            string                       IndudeinGalsync = Request.Form["IndudeinGalsync"].Trim().ToString();
            string                       Description     = Request.Form["Description"].Trim().ToString();
            string                       DisplayName     = Request.Form["DisplayName"].Trim().ToString();
            string                       HideFromOAB     = Request.Form["HideFromOAB"].Trim().ToString();
            Groups                       ad_group        = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO>             col             = ad_group.SearchAllGroupsDTO(userid, domain);
            GroupsDTO                    gd  = col.ElementAt(0);
            ExchangeDistributionGroupDTO EDG = new ExchangeDistributionGroupDTO(gd);

            EDG.Description = Description;
            EDG.DisplayName = DisplayName;
            if (HideFromOAB == "true")
            {
                EDG.HideFromOAB = true;
            }
            else
            {
                EDG.HideFromOAB = false;
            }
            if (RequireSenderAuthenticationEnabled == "true")
            {
                EDG.RequireSenderAuthenticationEnabled = true;
            }
            else
            {
                EDG.RequireSenderAuthenticationEnabled = false;
            }
            bool result = EDG.Update(ref estr);

            if (result)
            {
                return(Json(new JsonData("Successful modification!"), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new JsonData(estr), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 6
0
 public groupdto(GroupsDTO gd, string con, string members)
 {
     this.BelongsOUPath     = OuString.OuStringFormat(gd.BelongsOUPath);
     this.Description       = gd.Description;
     this.DisplayName       = gd.DisplayName;
     this.DistinguishedName = gd.DistinguishedName;
     this.Email             = gd.Email;
     this.isSecurityGroup   = gd.isSecurityGroup;
     this.ManagedBy         = gd.managedBy;
     this.SamAccountName    = gd.SamAccountName;
     this.GroupScope        = gd.GroupScope;
     this.MembersOf         = gd.MembersOf;
     this.memebertable      = con;
     this.Note    = gd.Note;
     this.Members = gd.Members;
     this.members = members;
 }
        public JsonResult ExchangeEnabled()
        {
            string           msg       = "";                               //Log日志要记录的用户名
            string           groupname = Request.Form["groupname"].Trim().ToString();
            string           domain    = Request.Form["domain"].Trim().ToString();
            Groups           ad_group  = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO> col       = ad_group.SearchAllGroupsDTO(groupname, domain);
            GroupsDTO        gd        = col.ElementAt(0);

            if (gd.ExchangeEnabled)
            {
                msg = "1";
            }
            else
            {
                msg = "0";
            }
            return(Json(new JsonData(msg)));
        }
        public JsonResult EnableGroupExchange()
        {
            string msg       = "";                                         //Log日志要记录的用户名
            string groupname = Request.Form["groupname"].Trim().ToString();
            string domain    = Request.Form["domain"].Trim().ToString();

            Groups ad_group = HttpContext.Application["ad_group"] as Groups;

            List <GroupsDTO> col = ad_group.SearchAllGroupsDTO(groupname, domain);
            GroupsDTO        gd  = col.ElementAt(0);

            if (gd.GroupScope != GroupScope.Universal)
            {
                gd.GroupScope = GroupScope.Universal;
            }
            bool result = ad_group.UpdateGroupsDTO(gd, ref msg);

            if (result)
            {
                ExchangeDistributionGroupDTO EDG = new ExchangeDistributionGroupDTO(gd);

                if (EDG.EnableDistributionGroup(ref msg))
                {
                    gd.ExchangeEnabled = true;
                    EDG = new ExchangeDistributionGroupDTO(gd);
                    msg = "1";
                }
                else
                {
                    msg = "0";
                }
            }
            else
            {
                msg = "0";
            }

            return(Json(new JsonData(msg)));
        }
 public void Setup()
 {
     var test = new GroupsDTO();
 }
Esempio n. 10
0
 public void UpdateGroup(GroupsDTO group)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
        public void DeleteGroup(GroupsDTO group)
        {
            var deleteGroup = mapper.Map <Groups>(group);

            repoGroup.Delete(deleteGroup);
        }
Esempio n. 12
0
        public void AddGroup(GroupsDTO group)
        {
            var addGroup = mapper.Map <Groups>(group);

            repoGroup.Create(addGroup);
        }
        public ActionResult ModifyExchange()
        {
            string keyword    = Request.QueryString["keyword"].Trim().ToString();
            string domainname = Request.QueryString["domain"].Trim().ToString();
            // string keyword = Request.Form["keyword"].Trim().ToString();


            Groups                       ad_group = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO>             col      = ad_group.SearchAllGroupsDTO(keyword, domainname);
            GroupsDTO                    gd       = col.ElementAt(0);
            ExchangeDistributionGroupDTO EDG      = new ExchangeDistributionGroupDTO(gd);

            List <SelectListItem> EmailHost = new List <SelectListItem>();
            string currentdb = EDG.PrimaryEmailAddress.Split('@')[1];

            EmailHost.Add(new SelectListItem {
                Text = "@" + currentdb, Value = currentdb
            });
            foreach (var Item in EDG.AcceptedDomain)
            {
                if (Item.ToString() != currentdb)
                {
                    EmailHost.Add(new SelectListItem {
                        Text = "@" + Item.ToString(), Value = Item.ToString()
                    });
                }
            }
            List <SelectListItem> Manager = new List <SelectListItem>();


            foreach (var Item in EDG.managedByList)
            {
                EmailHost.Add(new SelectListItem {
                    Text = Item.ToString(), Value = Item.ToString()
                });
            }
            List <SelectListItem> SendersAllowedList = new List <SelectListItem>();


            foreach (var Item in EDG.SendersAllowedList)
            {
                EmailHost.Add(new SelectListItem {
                    Text = Item.ToString(), Value = Item.ToString()
                });
            }


            GroupExchangeModel GEM = new GroupExchangeModel()
            {
                Description        = EDG.Description,
                DisplayName        = EDG.DisplayName,
                GroupName          = EDG.DisplayName,
                managedByList      = Manager,
                SendersAllowedList = SendersAllowedList,
                EmailHost          = EmailHost,
                Emailname          = EDG.PrimaryEmailAddress.Split('@')[0],
                HideFromAB         = EDG.HideFromOAB,
                RequireSenderAuthenticationEnabled = EDG.RequireSenderAuthenticationEnabled,
                IndudeinGalsync = EDG.IncludedInGalsync,
            };

            return(View(GEM));
        }                                 //显示数据
        public JsonResult Update()
        {
            string Operator = "";

            if (Session["username"].ToString() != null)
            {
                Operator = Session["username"].ToString();
            }                                                                       //Log日志要记录的用户名
            string        name        = Request.Form["name"].ToString();
            string        groupname   = Request.Form["groupname"].Trim().ToString();
            string        domain      = Request.Form["domain"].Trim().ToString();
            string        oupath      = Request.Form["oupath"].ToString();
            string        description = Request.Form["description"].Trim().ToString();
            string        email       = Request.Form["email"].Trim().ToString();
            string        note        = Request.Form["note"].Trim().ToString();
            string        manageby    = Request.Form["manageby"].ToString();
            string        numberof    = Request.Form["numberof"].ToString();
            string        grouptype   = Request.Form["grouptype"].Trim().ToString();
            string        groupscope  = Request.Form["groupscope"].ToString();
            int           leng        = numberof.Split(',').Length;
            List <string> MemberOf    = new List <string>();

            for (int i = 0; i < leng - 1; i++)
            {
                MemberOf.Add(numberof.Split(',')[i]);
            }
            string        members = Request.Form["Members"].ToString();
            int           len     = members.Split(',').Length;
            List <string> Members = new List <string>();

            for (int i = 0; i < len - 1; i++)
            {
                Members.Add(members.Split(',')[i]);
            }
            Groups           ad_group = HttpContext.Application["ad_group"] as Groups;
            List <GroupsDTO> col      = ad_group.SearchAllGroupsDTO(name, domain);
            GroupsDTO        gd       = col.ElementAt(0);

            if (groupscope.Equals("DomainLocale"))
            {
                gd.GroupScope = GroupScope.Local;
            }
            else if (groupscope.Equals("Gloable"))
            {
                gd.GroupScope = GroupScope.Global;
            }
            else
            {
                gd.GroupScope = GroupScope.Universal;
            }
            if (grouptype.Equals("Security"))
            {
                gd.isSecurityGroup = true;
            }
            gd.Description    = description;
            gd.SamAccountName = groupname;
            gd.Email          = email;
            gd.Note           = note;
            gd.managedBy      = manageby;
            gd.MembersOf      = MemberOf;
            gd.Members        = Members;
            string m;
            string msg = "";

            if (oupath != "")
            {
                if (ad_group.UpdateGroupsDTO(gd, ref msg) && ad_group.MoveGroupIntoNewOU(gd, oupath))
                {
                    m = "Successful modification!";
                    LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Modify%the%information%of%" + name.Replace(" ", ""), true);
                    return(Json(new JsonData(m, true)));
                }
                else
                {
                    m = "Modify failed! " + msg;
                    LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Modify%the%information%of%" + name.Replace(" ", ""), false);
                    return(Json(new JsonData(m, false)));
                }
            }
            else
            {
                if (ad_group.UpdateGroupsDTO(gd, ref msg))
                {
                    m = "Successful modification!";
                    LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Modify%the%information%of%" + name.Replace(" ", ""), true);
                    return(Json(new JsonData(m, true)));
                }
                else
                {
                    m = "Modify failed! " + msg;
                    LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Modify%the%information%of%" + name.Replace(" ", ""), false);
                    return(Json(new JsonData(m, false)));
                }
            }
        }
        public JsonResult Create()
        {
            string msg      = "";
            string Operator = "";

            if (Session["username"].ToString() != null)
            {
                Operator = Session["username"].ToString();
            }
            string    OuPath         = Request.Form["OuPath"].Trim().ToString();                                                        //Log日志要记录的用户名
            string    groupname      = Request.Form["groupname"].Trim().ToString();
            string    domain         = Request.Form["domain"].Trim().ToString();
            string    grouptype      = Request.Form["grouptype"].Trim().ToString();
            string    groupscope     = Request.Form["groupscope"].Trim().ToString();
            string    EnableExchange = Request.Form["EnableExchange"].Trim().ToString();
            Groups    ad_group       = HttpContext.Application["ad_group"] as Groups;
            GroupsDTO gd             = new GroupsDTO();

            gd.BelongsOUPath  = OuPath;
            gd.SamAccountName = groupname;
            if (grouptype.Equals("Security"))
            {
                gd.isSecurityGroup = true;
            }
            if (groupscope.Equals("DomainLocale"))
            {
                gd.GroupScope = GroupScope.Local;
            }
            else if (groupscope.Equals("Gloable"))
            {
                gd.GroupScope = GroupScope.Global;
            }
            else
            {
                gd.GroupScope = GroupScope.Universal;
            }

            string message;

            if (ad_group.CreateUserGroup(gd))
            {
                if (EnableExchange.Equals("true"))
                {
                    List <GroupsDTO>             col = ad_group.SearchAllGroupsDTO(groupname, domain);
                    GroupsDTO                    gd2 = col.ElementAt(0);
                    ExchangeDistributionGroupDTO EDG = new ExchangeDistributionGroupDTO(gd2);

                    if (EDG.EnableDistributionGroup(ref msg))
                    {
                        gd2.ExchangeEnabled = true;
                        EDG = new ExchangeDistributionGroupDTO(gd2);
                    }
                    else
                    {
                        msg = "error";
                    }
                }
                message = "Group:<span style =\"color:green\">" + groupname + "</span> create successful";
                LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Create%Group%named%" + groupname, true);
                XmlDocument doc = new XmlDocument();
                doc.Load(Server.MapPath("~/GroupDetail.xml"));
                XmlNode    rootnode = doc.SelectSingleNode("ADGroupDetail");
                XmlElement xe1      = doc.CreateElement("user");
                xe1.SetAttribute("Name", groupname);
                XmlElement xesub1 = doc.CreateElement("CreateBy");
                xesub1.InnerText = Operator;
                xe1.AppendChild(xesub1);
                XmlElement xesub2 = doc.CreateElement("CreateTime");
                xesub2.InnerText = DateTime.Today.ToString("yyyyMMdd");
                xe1.AppendChild(xesub2);
                rootnode.AppendChild(xe1);
                doc.Save(Server.MapPath("~/GroupDetail.xml"));
            }
            else
            {
                message = "Name for group <span style =\"color:green\">" + groupname + "</span>creation failed,It could be that the group already exists";
                LogHelper.WriteLog(typeof(GroupsManagementController), Operator, "Create%Group%named%" + groupname, false);
            }
            return(Json(new JsonData(message)));
        }