Example #1
0
        private MMessageProfile populateProfile(UIMessageProfile uiProfile, MAccountProfile accountProfile)
        {
            MMessageProfile mProfile = new MMessageProfile();

            if (accountProfile == null)
            {
                accountProfile = new MAccountProfile();
            }
            if (uiProfile.Id > 0)
            {
                mProfile             = MessageUtility.GetProfile(uiProfile.Id);
                mProfile.UpdatedBy   = accountProfile.Id;
                mProfile.UpdatedDate = DateTime.Now;
            }
            else
            {
                mProfile.AddedBy   = accountProfile.Id;
                mProfile.AddedDate = DateTime.Now;
            }
            mProfile.Body                = HttpContext.Current.Server.UrlDecode(uiProfile.Body);
            mProfile.Description         = uiProfile.Description;
            mProfile.FormatAsHtml        = uiProfile.FormatAsHtml;
            mProfile.Id                  = uiProfile.Id;
            mProfile.Name                = uiProfile.Name;
            mProfile.SecurityEntitySeqId = SecurityEntityUtility.CurrentProfile().Id;
            mProfile.Title               = uiProfile.Title;
            return(mProfile);
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Request.QueryString["messageSeqId"]))
     {
         int             mMessageSeqId = int.Parse(Request.QueryString["messageSeqId"].ToString());
         MMessageProfile mProfile      = new MMessageProfile();
         if (mMessageSeqId > -1)
         {
             mProfile = MessageUtility.GetProfile(mMessageSeqId);
         }
         HttpContext.Current.Session.Add("EditId", mProfile.Id);
         populatePage(mProfile);
     }
 }
Example #3
0
        public IHttpActionResult RequestChange(string account)
        {
            string                 mRetVal  = string.Empty;
            MAccountProfile        mProfile = AccountUtility.GetProfile(account);
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MMessageProfile        mMessageProfile        = MessageUtility.GetProfile("Request Password Reset UI");

            mRetVal = mMessageProfile.Body;
            string clearTextAccount = string.Empty;
            Logger mLog             = Logger.Instance();

            if (mProfile != null)
            {
                MAccountProfile mAccountProfile = mProfile;
                mAccountProfile.FailedAttempts = 0;
                mAccountProfile.Status         = 4;
                mAccountProfile.Password       = CryptoUtility.Encrypt(GWWebHelper.GetNewGuid, mSecurityEntityProfile.EncryptionType);
                mAccountProfile.UpdatedBy      = AccountUtility.GetProfile("anonymous").Id;
                mAccountProfile.UpdatedDate    = DateTime.Now;

                clearTextAccount = CryptoUtility.Decrypt(mProfile.Password, mSecurityEntityProfile.EncryptionType);
                try
                {
                    mMessageProfile = MessageUtility.GetProfile("RequestNewPassword");
                    MRequestNewPassword mRequestNewPassword = new MRequestNewPassword(mMessageProfile);
                    mRequestNewPassword.AccountName = HttpUtility.UrlEncode(CryptoUtility.Encrypt(mProfile.Account, mSecurityEntityProfile.EncryptionType));
                    mRequestNewPassword.FullName    = mProfile.FirstName + " " + mProfile.LastName;
                    mRequestNewPassword.Password    = HttpUtility.UrlEncode(mProfile.Password);
                    mRequestNewPassword.Server      = GWWebHelper.RootSite;
                    mProfile = AccountUtility.Save(mProfile, false, false);
                    NotifyUtility.SendMail(mRequestNewPassword, mProfile);
                    mLog.Debug("Reset password for account " + clearTextAccount);
                }
                catch (SmtpException ex)
                {
                    Exception myException = new Exception("Could not send e-mail." + ex.Message);
                    mLog.Error(myException);
                    mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("PasswordSendMailError");
                    mRetVal         = mMessageProfile.Body;
                }
                catch (Exception ex)
                {
                    Exception mException = new Exception("Could not set account details." + ex.Message);
                    mLog.Error(mException);
                    mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("ErrorAccountDetails");
                    mRetVal         = mMessageProfile.Body;
                }
            }
            return(Ok(mRetVal));
        }
Example #4
0
        public string SetSelectedSecurityEntity(int selectedSecurityEntityId)
        {
            MSecurityEntityProfile targetSEProfile     = SecurityEntityUtility.GetProfile(selectedSecurityEntityId);
            MSecurityEntityProfile currentSEProfile    = SecurityEntityUtility.CurrentProfile();
            MClientChoicesState    mClientChoicesState = (MClientChoicesState)HttpContext.Current.Cache[MClientChoices.SessionName];
            MMessageProfile        mMessageProfile     = null;

            try
            {
                if (!ConfigSettings.CentralManagement)
                {
                    //SecurityEntityUtility.SetSessionSecurityEntity(targetSEProfile)
                    mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString(CultureInfo.InvariantCulture);
                    mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                }
                else
                {
                    if (currentSEProfile.ConnectionString == targetSEProfile.ConnectionString)
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString(CultureInfo.InvariantCulture);
                        mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                    }
                    else
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = ConfigSettings.DefaultSecurityEntityId.ToString(CultureInfo.InvariantCulture);
                        mClientChoicesState[MClientChoices.SecurityEntityName] = "System";
                    }
                }
                ClientChoicesUtility.Save(mClientChoicesState);
                AccountUtility.RemoveInMemoryInformation(true);
                mMessageProfile = MessageUtility.GetProfile("ChangedSelectedSecurityEntity");
            }
            catch (Exception ex)
            {
                MMessageProfile myMessageProfile = new MMessageProfile();
                Logger          mLog             = Logger.Instance();
                mMessageProfile = MessageUtility.GetProfile("NoDataFound");
                Exception myEx = new Exception("SelectSecurityEntity:: reported an error.", ex);
                mLog.Error(myEx);
            }
            // update all of your in memory information
            return(mMessageProfile.Body);
        }
Example #5
0
        public IHttpActionResult SelectSecurityEntity([FromUri] int selectedSecurityEntityId)
        {
            MSecurityEntityProfile targetSEProfile     = SecurityEntityUtility.GetProfile(selectedSecurityEntityId);
            MSecurityEntityProfile currentSEProfile    = SecurityEntityUtility.CurrentProfile();
            MClientChoicesState    mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(AccountUtility.CurrentProfile().Account);
            MMessageProfile        mMessageProfile     = null;

            try
            {
                if (!ConfigSettings.CentralManagement)
                {
                    mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString();
                    mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                }
                else
                {
                    if (currentSEProfile.ConnectionString == targetSEProfile.ConnectionString)
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString();
                        mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                    }
                    else
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = ConfigSettings.DefaultSecurityEntityId.ToString();
                        mClientChoicesState[MClientChoices.SecurityEntityName] = "System";
                    }
                }
                MMessageProfile myMessageProfile = new MMessageProfile();
                // update all of your in memory information
                AccountUtility.RemoveInMemoryInformation(true);
                ClientChoicesUtility.Save(mClientChoicesState);
                mMessageProfile = MessageUtility.GetProfile("ChangedSelectedSecurityEntity");
            }
            catch (Exception ex)
            {
                Logger mLog = Logger.Instance();
                mMessageProfile = MessageUtility.GetProfile("NoDataFound");
                Exception myEx = new Exception("SelectSecurityEntity:: reported an error.", ex);
                mLog.Error(myEx);
            }
            // refresh the view
            return(Ok(mMessageProfile.Body));
        }
Example #6
0
        public IHttpActionResult ChangePassword(MChangePassword mChangePassword)
        {
            if (mChangePassword == null)
            {
                throw new ArgumentNullException("mChangePassword", "mChangePassword cannot be a null reference (Nothing in Visual Basic)!");
            }
            MMessageProfile        mMessageProfile        = new MMessageProfile();
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MAccountProfile        mAccountProfile        = AccountUtility.CurrentProfile();
            string mCurrentPassword = "";

            mMessageProfile = MessageUtility.GetProfile("SuccessChangePassword");
            try
            {
                mCurrentPassword = CryptoUtility.Decrypt(mAccountProfile.Password, mSecurityEntityProfile.EncryptionType);
            }
            catch (Exception)
            {
                mCurrentPassword = mAccountProfile.Password;
            }
            if (mAccountProfile.Status != (int)SystemStatus.ChangePassword)
            {
                if (mChangePassword.OldPassword != mCurrentPassword)
                {
                    mMessageProfile = MessageUtility.GetProfile("PasswordNotMatched");
                }
                else
                {
                    mAccountProfile.PasswordLastSet = System.DateTime.Now;
                    mAccountProfile.Status          = (int)SystemStatus.Active;
                    mAccountProfile.FailedAttempts  = 0;
                    mAccountProfile.Password        = CryptoUtility.Encrypt(mChangePassword.NewPassword.Trim(), mSecurityEntityProfile.EncryptionType);
                    try
                    {
                        AccountUtility.Save(mAccountProfile, false, false);
                    }
                    catch (Exception)
                    {
                        mMessageProfile = MessageUtility.GetProfile("UnSuccessChangePassword");
                    }
                }
            }
            else
            {
                try
                {
                    var _with2 = mAccountProfile;
                    _with2.PasswordLastSet = System.DateTime.Now;
                    _with2.Status          = (int)SystemStatus.Active;
                    _with2.FailedAttempts  = 0;
                    _with2.Password        = CryptoUtility.Encrypt(mChangePassword.NewPassword.Trim(), mSecurityEntityProfile.EncryptionType);
                    AccountUtility.Save(mAccountProfile, false, false);
                }
                catch (Exception)
                {
                    mMessageProfile = MessageUtility.GetProfile("UnSuccessChangePassword");
                }
            }
            AccountUtility.RemoveInMemoryInformation(true);
            return(Ok(mMessageProfile.Body));
        }
Example #7
0
        public IHttpActionResult Logon(LogonInfo jsonData)
        {
            if (jsonData == null)
            {
                throw new ArgumentNullException("jsonData", "jsonData cannot be a null reference (Nothing in Visual Basic)!");
            }
            if (string.IsNullOrEmpty(jsonData.Account))
            {
                throw new NullReferenceException("jsonData.Account cannot be a null reference (Nothing in Visual Basic)!");
            }
            if (string.IsNullOrEmpty(jsonData.Password))
            {
                throw new NullReferenceException("jsonData.Password cannot be a null reference (Nothing in Visual Basic)!");
            }
            string mRetVal       = "false";
            bool   mDomainPassed = false;

            if (jsonData.Account.Contains("\\"))
            {
                mDomainPassed = true;
            }
            if (ConfigSettings.AuthenticationType.ToUpper() == "LDAP" & !mDomainPassed)
            {
                jsonData.Account = ConfigSettings.LdapDomain + "\\" + jsonData.Account;
            }
            if (AccountUtility.Authenticated(jsonData.Account, jsonData.Password))
            {
                MAccountProfile mAccountProfile = AccountUtility.GetProfile(jsonData.Account);
                mAccountProfile.LastLogOn = DateTime.Now;
                if (mAccountProfile.Status == Convert.ToInt32(SystemStatus.Disabled))
                {
                    mAccountProfile.Status = Convert.ToInt32(SystemStatus.Active);
                }
                mAccountProfile.FailedAttempts = 0;
                AccountUtility.Save(mAccountProfile, false, false);
                AccountUtility.SetPrincipal(mAccountProfile);
                mRetVal = "true";
            }
            else
            {
                MAccountProfile mAccountProfile = AccountUtility.GetProfile(jsonData.Account);
                if (mAccountProfile != null)
                {
                    if (mAccountProfile.Account.ToUpper(new CultureInfo("en-US", false)) == jsonData.Account.ToUpper(new CultureInfo("en-US", false)))
                    {
                        if (ConfigSettings.AuthenticationType.ToUpper() == "INTERNAL")
                        {
                            if (mAccountProfile.Status != Convert.ToInt32(SystemStatus.Disabled) || mAccountProfile.Status != Convert.ToInt32(SystemStatus.Inactive))
                            {
                                mRetVal = "Request";
                            }
                            else
                            {
                                MMessageProfile mMessageProfile = MessageUtility.GetProfile("DisabledAccount");
                                if (mMessageProfile != null)
                                {
                                    mRetVal = mMessageProfile.Body;
                                }
                            }
                        }
                        else
                        {
                            MMessageProfile mMessageProfile = MessageUtility.GetProfile("Logon Error");
                            if (mMessageProfile != null)
                            {
                                mRetVal = mMessageProfile.Body;
                            }
                        }
                    }
                }
                else
                {
                    MMessageProfile mMessageProfile = MessageUtility.GetProfile("Logon Error");
                    if (mMessageProfile != null)
                    {
                        mRetVal = mMessageProfile.Body;
                    }
                }
            }

            return(Ok(mRetVal));
        }