Beispiel #1
0
        /// <summary>
        /// Gets the security status of the current user and enables features based on their status.
        /// </summary>
        /// <returns>true if the current user has sufficient permission to use the application.</returns>
        /// <remarks>
        /// This method uses the <see cref="SecurityComponent(User)"/> to grab security roles from the
        /// Data Integration Hub on PCI-DB. It closes frmMain if an error occurs.
        /// </remarks>
        private bool LoginCurrentUser()
        {
            // Attempt to log the user in
            try
            {
#if DEBUG
                CurrentUser = new User(Environment.UserDomainName + "\\" + "khalberg");
#else
                CurrentUser = new User(Environment.UserDomainName + "\\" + Environment.UserName);
#endif

                Security            = new SecurityComponent(CurrentUser);
                lblLoginStatus.Text = "You are logged in as: " + CurrentUser.DomainName;

                if (Security.IsAdmin() == false)
                {
                    lblSettings.Enabled = false;
                    lblSettings.Visible = false;
                }

                if (Security.IsUser() == false && Security.IsAdmin() == false)
                {
                    MessageBox.Show("You do not sufficient security privileges to use this application. Please see your system administrator.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }

            BeginCurrentSession();

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Represents the main form of the VSP application.
        /// </summary>
        public frmMain()
        {
            InitializeComponent();

            this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;

            #region IMessageFilter Methods

            //Add controls to move the form
            Application.AddMessageFilter(this);
            controlsToMove.Add(this.lblFormHeader);
            controlsToMove.Add(this.panel6);
            controlsToMove.Add(this.panel10);
            controlsToMove.Add(this.pnlMainHeader);

            #endregion

            if (!ConnectionSucceeded())
            {
                return;
            }

            bool isAccessUser = LoginCurrentUser();
            if (isAccessUser == false)
            {
                Environment.Exit(1);
                return;
            }

            SecurityComponent securityComponent = new SecurityComponent(CurrentUser);
            if (securityComponent.IsAdmin() == false)
            {
                lblSettings.Visible = false;
                lblQA.Visible       = false;
            }

            HandleAppVersion();

            //Start app with the dashboard tab
            tabMain.SelectedIndex = 8;

            CurrentTabLabel = lblClients; // Clients tab label
            highlightSelectedTabLabel(CurrentTabLabel);

            SetDefaultComboBoxValues();
        }