예제 #1
0
        public string ResetPasswordAndRedirect(BOPasswordReset passwordReset)
        {
            SessionInfo objInfo      = new SessionInfo();
            string      errorMessage = "";

            try
            {
                using (SessionPortClient objClient = new SessionPortClient("BOSession"))
                {
                    _logMessages.AppendFormat("Performing password reset for user:{0}.", passwordReset.Username);
                    if (passwordReset.AccountLocked)
                    {
                        _logMessages.AppendFormat("Account locked.Performing change password for user:{0}.", passwordReset.Username);
                        objClient.changePassword(passwordReset.SAPLoginToken, passwordReset.OldPassword, passwordReset.NewPassword);
                    }
                    else
                    {
                        EnterpriseCredential creds = new EnterpriseCredential();
                        creds.Login    = passwordReset.Username;
                        creds.Password = passwordReset.OldPassword;
                        creds.AuthType = "secEnterprise";

                        _logMessages.Append("Performing logon to the sap BO");

                        objInfo = objClient.login(creds, "");
                        if (objInfo != null)
                        {
                            objClient.changePassword(objInfo.SessionID, passwordReset.OldPassword, passwordReset.NewPassword);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                errorMessage = ex.Message;
                _logMessages.AppendFormat("Error occurred in password reset. Exception message {0}.", ex.Message);
                _logger.Info(_logMessages.ToString());
                return(errorMessage);
            }
            _logger.Info(_logMessages.ToString());
            return(errorMessage);
        }