コード例 #1
0
        public GroupMappingPanel(Configuration config)
        {
            InitializeComponent();
            labels   = new ArrayList();
            textBoxs = new ArrayList();

            this.config  = config;
            amSection    = (AppSettingsSection)config.Sections["AMSettings"];
            groupSection = (AppSettingsSection)config.Sections["GroupMappings"];

            Label typeLabel = new Label();

            typeLabel.Text        = "Map user groups between ActiveDirectory and AlertMedia using either one of the below approaches";
            typeLabel.AutoSize    = true;
            typeLabel.MaximumSize = new Size(600, 0);
            typeLabel.Location    = new Point(170, 10);
            this.Controls.Add(typeLabel);

            ouButton          = new RadioButton();
            ouButton.Text     = "OU Mappings";
            ouButton.AutoSize = true;
            ouButton.Location = new Point(150, 25);
            this.Controls.Add(ouButton);
            ouButton.Click += new System.EventHandler(this.ouButton_Click);

            fvButton          = new RadioButton();
            fvButton.Text     = "Field Value Mappings";
            fvButton.Location = new Point(300, 25);
            fvButton.AutoSize = true;
            this.Controls.Add(fvButton);
            fvButton.Click += new System.EventHandler(this.fvButton_Click);

            noButton          = new RadioButton();
            noButton.Text     = "Skip Group Mapping";
            noButton.AutoSize = true;
            noButton.Location = new Point(450, 25);
            this.Controls.Add(noButton);
            noButton.Click += new System.EventHandler(this.noButton_Click);

            GroupBox lineBox = new GroupBox();

            lineBox.Text   = "";
            lineBox.Width  = 730;
            lineBox.Height = 1;
            lineBox.Paint += delegate(object o, PaintEventArgs p)
            {
                p.Graphics.Clear(Color.Gray);
            };
            lineBox.Location = new Point(5, 50);
            this.Controls.Add(lineBox);

            configFieldBox            = new Panel();
            configFieldBox.AutoScroll = true;
            configFieldBox.Width      = 700;
            configFieldBox.Height     = 320;
            configFieldBox.Location   = new Point(25, 70);
            this.Controls.Add(configFieldBox);

            mapGroupsBT          = new Button();
            mapGroupsBT.AutoSize = true;
            mapGroupsBT.Click   += new System.EventHandler(this.mapsGroups_Button_Click);
            mapGroupsBT.Text     = "Update";
            mapGroupsBT.Location = new Point(200, 400);
            this.Controls.Add(mapGroupsBT);

            Button prevBT = new Button();

            prevBT.AutoSize = true;
            prevBT.Click   += new System.EventHandler(this.prev_Button_Click);
            prevBT.Text     = "Back";
            prevBT.Location = new Point(300, 400);
            this.Controls.Add(prevBT);

            Button nextBT = new Button();

            nextBT.AutoSize = true;
            nextBT.Click   += new System.EventHandler(this.next_Button_Click);
            nextBT.Text     = "Next";
            nextBT.Location = new Point(400, 400);
            this.Controls.Add(nextBT);

            descLabel             = new Label();
            descLabel.Text        = "";
            descLabel.AutoSize    = true;
            descLabel.MaximumSize = new Size(600, 0);
            descLabel.Location    = new Point(25, 5);
            configFieldBox.Controls.Add(descLabel);

            this.fieldBox2       = new Panel();
            fieldBox2.AutoScroll = true;
            fieldBox2.Width      = 225;
            fieldBox2.Height     = 250;
            fieldBox2.Location   = new Point(5, 50);
            configFieldBox.Controls.Add(fieldBox2);

            this.displayGroupMappingScreen();

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                client     = new ActiveDirectoryClient(this.config);
                groupList  = client.getActiveDirectoryUserGroups();
                userObject = client.userFieldMappings;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Not able to connect to your Active Directory Server. Please check you internet connection and try again. If problem persists, please contact your internal support team.");
                Cursor.Current = Cursors.Default;
                return;
            }
            Cursor.Current = Cursors.Default;

            this.groupMappingType = amSection.Settings["GroupMappingType"].Value;
            if (this.groupMappingType.Equals("OU"))
            {
                ouButton.Checked = true;
                ouButton.PerformClick();
            }
            else if (this.groupMappingType.Equals("FieldValue"))
            {
                fvButton.Checked = true;
                fvButton.PerformClick();
            }
            else if (this.groupMappingType.Equals(""))
            {
                noButton.Checked = true;
                noButton.PerformClick();
            }
        }