Пример #1
0
        private void btnGetADUser_Click(object sender, EventArgs e)
        {
            Boolean ReplaceAll = false;
            ArrayList lstUser = new ArrayList();
            object[] myRet = CliUtils.CallMethod("GLModule", "GetADUsers", new object[] { });
            if ((null != myRet) && (0 == (int)myRet[0]))
            {
                lstUser = ((ArrayList)myRet[1]);

                lstUser = SelectADObject(SortADObject(lstUser));

                foreach (ADUser user in lstUser)
                {
                    DataRow druser = null;
                    DataRow[] drintables = infoDsUsers.RealDataSet.Tables[0].Select("USERID='" + user.ID + "'");
                    if (drintables.Length > 0)
                    {
                        if (ReplaceAll)
                        {
                            druser = drintables[0];
                        }
                        else
                        {
                            fmReplaceDialog aDialog = new fmReplaceDialog(string.Format("Replace {0} infomation by AD defination?", user.ID));
                            DialogResult aResult = aDialog.ShowDialog(this);
                            switch (aResult)
                            {
                                case DialogResult.OK:
                                    druser = drintables[0];
                                    break;
                                case DialogResult.Retry:
                                    ReplaceAll = true;
                                    druser = drintables[0];
                                    break;
                                case DialogResult.Cancel:
                                    continue;
                                //break;
                                default:
                                    continue;
                                //break;
                            }
                        }
                    }
                    else
                    {
                        druser = infoDsUsers.RealDataSet.Tables[0].NewRow();
                        druser["USERID"] = user.ID;
                        druser["AUTOLOGIN"] = "";
                        infoDsUsers.RealDataSet.Tables[0].Rows.Add(druser);
                    }
                    druser["USERNAME"] = user.Name;
                    druser["DESCRIPTION"] = user.Description;
                    druser["EMAIL"] = user.Email;
                    druser["MSAD"] = "Y";
                }
                infoDsUsers.ApplyUpdates();
            }
        }
Пример #2
0
        private void btnGetADGroup_Click(object sender, EventArgs e)
        {
            Boolean ReplaceAll = false;
            ArrayList lstGroup = new ArrayList();
            object[] myRet = CliUtils.CallMethod("GLModule", "GetADUserForGroup", new object[] { });
            if ((null != myRet) && (0 == (int)myRet[0]))
            {
                lstGroup = ((ArrayList)myRet[1]);

                lstGroup = SelectADObject(SortADObject(lstGroup));

                foreach (ADGroup group in lstGroup)
                {
                    DataRow drgroup = null;
                    DataRow[] drintables = infoDsGroups.RealDataSet.Tables[0].Select("GROUPNAME='" + group.ID + "'");
                    if (drintables.Length > 0)
                    {
                        if (ReplaceAll)
                        {
                            drgroup = drintables[0];
                        }
                        else
                        {
                            fmReplaceDialog aDialog = new fmReplaceDialog(string.Format("Replace {0} infomation by AD defination?", group.ID));
                            DialogResult aResult = aDialog.ShowDialog(this);
                            switch (aResult)
                            {
                                case DialogResult.OK:
                                    drgroup = drintables[0];
                                    break;
                                case DialogResult.Retry:
                                    ReplaceAll = true;
                                    drgroup = drintables[0];
                                    break;
                                case DialogResult.Cancel:
                                    continue;
                                //break;
                                default:
                                    continue;
                                //break;
                            }
                        }
                    }
                    else
                    {
                        drgroup = infoDsGroups.RealDataSet.Tables[0].NewRow();
                        drgroup["GROUPID"] = "ad" + GetGroupID().ToString("000");
                        drgroup["GROUPNAME"] = group.ID;
                        infoDsGroups.RealDataSet.Tables[0].Rows.Add(drgroup);
                    }
                    drgroup["DESCRIPTION"] = group.Description;
                    drgroup["MSAD"] = "Y";
                    foreach (string user in group.Users)
                    {
                        DataRow[] useringroup = infoDsGroups.RealDataSet.Tables[1].Select("GROUPID='" + drgroup["GROUPID"]
                            + "' and USERID='" + user + "'");
                        if (useringroup.Length == 0)
                        {
                            DataRow druser = infoDsGroups.RealDataSet.Tables[1].NewRow();
                            druser["GROUPID"] = drgroup["GROUPID"];
                            druser["USERID"] = user;
                            infoDsGroups.RealDataSet.Tables[1].Rows.Add(druser);
                        }
                    }
                }
                infoDsGroups.ApplyUpdates();
            }
        }