Example #1
0
        private static eLoginEnum Connect(String AUserName, String APassword, Int64 ASiteKey)
        {
            eLoginEnum ConnectionResult;
            String     WelcomeMessage;
            String     LoginError;
            Int32      ProcessID;
            Boolean    SystemEnabled;

            TLogging.Log("connecting UserId: " + AUserName + " to Server...");
            ConnectionResult = ((TConnectionManagement)TConnectionManagement.GConnectionManagement).ConnectToServer(
                AUserName.ToUpper(), APassword,
                out ProcessID,
                out WelcomeMessage,
                out SystemEnabled,
                out LoginError);

            if (ConnectionResult != eLoginEnum.eLoginSucceeded)
            {
                TLogging.Log("Connection to PetraServer failed! ConnectionResult: " + ConnectionResult.ToString() + " Error: " + LoginError);
                return(ConnectionResult);
            }

            TUserDefaults.InitUserDefaults();
            new TServerInfo(Utilities.DetermineExecutingOS());
            TLogging.Log(
                "client is connected ClientID: " + TConnectionManagement.GConnectionManagement.ClientID.ToString() + " UserId: " + AUserName +
                " to Server...");

            return(eLoginEnum.eLoginSucceeded);
        }
Example #2
0
        private static void Connect(String AUserName, String APassword, Int64 ASiteKey)
        {
            bool    ConnectionResult;
            String  WelcomeMessage;
            String  LoginError;
            Int32   ProcessID;
            Boolean SystemEnabled;

            TLogging.Log("connecting UserId: " + AUserName + " to Server...");
            try
            {
                ConnectionResult = ((TConnectionManagement)TConnectionManagement.GConnectionManagement).ConnectToServer(
                    AUserName.ToUpper(), APassword,
                    out ProcessID,
                    out WelcomeMessage,
                    out SystemEnabled,
                    out LoginError);

                if (!ConnectionResult)
                {
                    TLogging.Log("Connection to PetraServer failed! ConnectionResult: " + ConnectionResult + " Error: " + LoginError);
                    return;
                }
            }
            catch (EServerConnectionServerNotReachableException)
            {
                throw;
            }
            catch (ELoginFailedServerTooBusyException)
            {
                TLogging.Log("Login failed because server was too busy.");
                throw;
            }
            catch (EDBConnectionNotEstablishedException exp)
            {
                if (exp.Message.IndexOf("Exceeding permissible number of connections") != -1)
                {
                    throw new Exception("Login failed because too many users are logged in.");
                }
                else
                {
                    throw;
                }
            }
            catch (EServerConnectionGeneralException)
            {
                throw;
            }
            TUserDefaults.InitUserDefaults();
            new TServerInfo(Utilities.DetermineExecutingOS());
            TLogging.Log(
                "client is connected ClientID: " + TConnectionManagement.GConnectionManagement.ClientID.ToString() + " UserId: " + AUserName +
                " to Server...");
        }
Example #3
0
        // Button 'Login' pressed
        private void BtnLoginClick(System.Object sender, System.EventArgs e)
        {
            FConnectionEstablished = false;

            // Get the selected User Name and Password
            FSelUserName = this.txtUserName.Text.ToUpper();
            FSelPassWord = (this.txtPassword.Text);

            if ((FSelUserName.Length == 0) || (FSelPassWord.Length == 0))
            {
                MessageBox.Show(Catalog.GetString("Please enter a User ID and a Password to log in into OpenPetra."),
                                StrPetraLoginFormTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                SetFocusToCredentials();

                return;
            }

            // don't waste a try for authentication if the CapsLock is on; otherwise the user is retired quite quickly
            if (Control.IsKeyLocked(Keys.CapsLock))
            {
                MessageBox.Show(Catalog.GetString("The Caps Lock key is ON. Please switch it off and try to login again"),
                                StrPetraLoginFormTitle);

                SetFocusToCredentials();

                return;
            }

            /* Now authenticate User against the Petra Server.
             *
             * Note: Authenticate has to establish a connection to the Petra Server first
             */
            String ConnectionError;

            this.Cursor = Cursors.WaitCursor;

            StoreUserName(FSelUserName);

            UpdateUI(true);

            if (ConnectToPetraServer(FSelUserName, FSelPassWord, out ConnectionError))
            {
                prbLogin.Value = 90;
                bool MustChangePassword = false;

                // Show any message that is returned after successful login (eg. 'Petra is currently disabled due to xxx. Proceed with caution.')
                if (UserInfo.GUserInfo.LoginMessage != null)
                {
                    // If the user is required to change their password before using OpenPetra.
                    // (This LoginMessage is set in Ict.Petra.Server.MSysMan.Security.UserManager.WebConnectors.TUserManagerWebConnector)
                    MustChangePassword = (UserInfo.GUserInfo.LoginMessage == SharedConstants.LOGINMUSTCHANGEPASSWORD);

                    if (!MustChangePassword)
                    {
                        MessageBox.Show(UserInfo.GUserInfo.LoginMessage,
                                        StrPetraLoginFormTitle,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }

                TUserDefaults.InitUserDefaults();
                prbLogin.Value          = 100;
                FConnectionEstablished  = true;
                this.Cursor             = Cursors.Default;
                TLogging.UserNamePrefix = UserInfo.GUserInfo.UserID + '_' +
                                          TConnectionManagement.GConnectionManagement.ClientID.ToString();

                UpdateUI(false);

                if (MustChangePassword)
                {
                    if (!CreateNewPassword(this, FSelUserName, FSelPassWord, true))
                    {
                        // do nothing if password has not been successfully changed
                        return;
                    }
                }

                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
            else
            {
                this.Cursor = Cursors.Default;

                UpdateUI(false);

                // TODORemoting do not show the error code???
                if ((ConnectionError.Length > 0) && (ConnectionError.IndexOf(" ") != -1))
                {
                    // this message box shows if the password is wrong
                    // otherwise there has already been a message box usually
                    MessageBox.Show(ConnectionError, StrPetraLoginFormTitle, MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    SetFocusToCredentials();
                }
            }
        }