Beispiel #1
0
        /*
         * Logs the user and creates the connection to active directory
         */
        private void btnLogin_Click(object sender, EventArgs e)
        {
            _logger.Info("Login button clicked");

            // get username and password
            Variables.userName     = txtUsername.Text.Trim();
            Variables.userPassword = txtPassword.Text.Trim();

            // error check to make sure username and password is not blank
            if ((txtPassword.Text.Trim().Length == 0) || (txtUsername.Text.Trim().Length == 0))
            {
                const string errorBlankMessage = "Username or Password is blank, please recheck and try again";
                const string errorBlankCaption = "Username or Password Blank";

                MessageBox.Show(errorBlankMessage, errorBlankCaption,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }

            else
            {
                // retrieve settings saved in user application properties
                _logger.Debug("Reading in saved settings");

                Util.UpdateSettings(); //update the settings

                _logger.Debug("Starting Search Path is " + Variables.searchPath);
                _logger.Debug("Starting Directory Domain is " + Variables.directoryDomain);
                _logger.Debug("Starting Directory Server is " + Variables.directoryServer);

                Util.MakeLDAPSearch(); // Make the formal LDAP search path from user settings

                try {
                    DirectoryEntry _conn = Util.CreateDirConnection();
                    _logger.Debug("Active Directory connection successful");
                    this.Hide();
                    frmUserList mainFrm = new frmUserList();
                    mainFrm.Show();
                }
                catch (Exception excep) {
                    _logger.Error("There was an error logging in" + excep.StackTrace);

                    const string errorMessage = "There was an error logging in, Please see the log for more details";
                    const string errorCaption = "Error logging in";

                    MessageBox.Show(errorMessage, errorCaption,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
Beispiel #2
0
        /*
         * Logs the user and creates the connection to active directory
         */
        private void btnLogin_Click(object sender, EventArgs e) {
            _logger.Info("Login button clicked");

            // get username and password
            Variables.userName = txtUsername.Text.Trim();
            Variables.userPassword = txtPassword.Text.Trim();

            // error check to make sure username and password is not blank
            if ((txtPassword.Text.Trim().Length == 0) || (txtUsername.Text.Trim().Length == 0)) {

                const string errorBlankMessage = "Username or Password is blank, please recheck and try again";
                const string errorBlankCaption = "Username or Password Blank";

                MessageBox.Show(errorBlankMessage, errorBlankCaption,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }

            else {
                // retrieve settings saved in user application properties
                _logger.Debug("Reading in saved settings");

                Util.UpdateSettings(); //update the settings

                _logger.Debug("Starting Search Path is " + Variables.searchPath);
                _logger.Debug("Starting Directory Domain is " + Variables.directoryDomain);
                _logger.Debug("Starting Directory Server is " + Variables.directoryServer);

                Util.MakeLDAPSearch(); // Make the formal LDAP search path from user settings

                try {
                    DirectoryEntry _conn = Util.CreateDirConnection();
                    _logger.Debug("Active Directory connection successful");
                    this.Hide();
                    frmUserList mainFrm = new frmUserList();
                    mainFrm.Show();
                }
                catch (Exception excep) {
                    _logger.Error("There was an error logging in" + excep.StackTrace);

                    const string errorMessage = "There was an error logging in, Please see the log for more details";
                    const string errorCaption = "Error logging in";

                    MessageBox.Show(errorMessage, errorCaption,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }