Example #1
0
        public void SetCache(string sessionid, DCUser2 dcusr)
        {
            Guid gd = Guid.NewGuid();

            CacheMgr.Add <string>(CryptoUtils.DecryptTripleDES(sessionid), gd.ToString());
            CacheMgr.Add <DCUser2>(gd.ToString(), dcusr);
        }
Example #2
0
        public DCUser2 AuthenticateUser(string sessionid, string username, string pwd, string pwdattempts)
        {
            UserBiz     m_ubiz = new UserBiz();
            User2Detail dtuser = null;
            DCUser2     dcusr  = null;
            GroupBiz    m_gbiz = new GroupBiz();

            try
            {
                dtuser = m_ubiz.AuthenticateUser(CryptoUtils.DecryptTripleDES(username), CryptoUtils.DecryptTripleDES(pwd),
                                                 GMConvert.GetInt16(CryptoUtils.DecryptTripleDES(pwdattempts)));
                if (dtuser != null && dtuser.LastLogon.HasValue)
                {
                    dtuser.Permissions = new List <int>();
                    List <Int32> groups = m_ubiz.GetGroups(dtuser.ID);
                    foreach (int group in groups)
                    {
                        dtuser.Permissions.AddRange(m_gbiz.GetPermissions(group));
                    }

                    dcusr = new DCUser2();
                    GMReflectionUtils.Copy(dtuser, dcusr);
                    SetCache(sessionid, dcusr);
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally { m_ubiz.Dispose(); m_gbiz.Dispose(); }
            return(dcusr);
        }
Example #3
0
        public bool HasPermission(Permission pn)
        {
            bool    rv   = false;
            DCUser2 user = GetToken();

            if (user != null)
            {
                rv = user.Permissions.Contains((int)pn);
            }
            return(rv);
        }
Example #4
0
        public BaseDC GetHeaderToken(BaseDC bdc)
        {
            DCUser2 dcusr = GetToken();

            bdc.IsActive          = dcusr.IsActive;
            bdc.IsChangePasssword = dcusr.IsChangePasssword;
            bdc.IsLocked          = dcusr.IsLocked;
            bdc.UserID            = dcusr.ID;
            bdc.Username          = string.Format("( {0} {1}, Log-in Time: {2} )", dcusr.FirstName, dcusr.LastName, dcusr.LastLogon.Value.ToShortTimeString());
            return(bdc);
        }
Example #5
0
 public void Save(DCUser2 dcusr)
 {
     try
     {
         User2Detail detusr = new User2Detail();
         GMUtilities.GMReflectionUtils.Copy(dcusr, detusr);
         Save(detusr, (bool)dcusr.IsPasswordChangedManual);
         if ((bool)dcusr.IsPasswordChangedManual)
         {
             dcusr          = GetCache(dcusr.SessionID);
             dcusr.Password = CryptoUtils.EncryptSHA(dcusr.Password);
             SetCache(dcusr.SessionID, dcusr);
         }
     }
     catch (Exception exp)
     { throw exp; }
 }
Example #6
0
        private void ValidateUser(Int16 PasswordAttempt, string returnURL)
        {
            AuthenticationUB auth   = new AuthenticationUB();
            DCUser2          dcuser = null;

            try
            {
                dcuser = auth.AuthenticateUser(this.Page.Session.SessionID, txtUserID.Value, txtPassword.Value, PasswordAttempt);
                GMReflectionUtils.InvokeMember(this.Page, ReflectionConstants.ValidateToken, new object[] { dcuser, txtUserID.Value, returnURL }, EnumConstants.InvokeMethod);
            }
            catch (Exception ex) { throw ex; }
            finally
            {
                auth   = null;
                dcuser = null;
            }
        }
Example #7
0
        public void Get(DCUser2 dcusr)
        {
            GroupBiz gbiz = new GroupBiz();

            try
            {
                GMUtilities.GMReflectionUtils.Copy(m_biz.Get(dcusr.ID), dcusr);
                dcusr.DSUNSelected   = gbiz.Get();
                dcusr.DSTypeID       = m_optbiz.GetEmployeeTypes(GetCache(dcusr.SessionID).ID);
                dcusr.DSDepartmentID = m_optbiz.GetDeparmentTypes();
                if (dcusr.ID.HasValue)
                {
                    dcusr.DSSelected = GMUtilities.DataUtils.DetachSelection(dcusr.DSUNSelected, m_biz.GetGroups(dcusr.ID));
                }
            }
            catch (Exception exp) { throw exp; }
            finally { gbiz.Dispose(); }
        }
Example #8
0
        public void ChangePassword(string sessionid, string userid, string oldpwd, string newpwd)
        {
            DCUser2 dcusr = GetCache(sessionid);

            if (string.Compare(dcusr.Password, CryptoUtils.EncryptSHA(oldpwd), true) != 0)
            {
                throw new ApplicationException(ErrorConstants.ExistingPassword);
            }
            User2Detail detusr = new User2Detail();

            detusr.ID                 = (Int32?)GMConvert.GetInt32(userid);
            detusr.Password           = CryptoUtils.EncryptSHA(newpwd);
            detusr.LastPassword       = CryptoUtils.EncryptSHA(oldpwd);
            detusr.PasswordChangeDate = DateTime.Now;
            detusr.IsChangePasssword  = false;
            detusr.ModifiedDate       = DateTime.Now;
            Save(detusr);
            dcusr.Password          = CryptoUtils.EncryptSHA(newpwd);
            dcusr.IsChangePasssword = false;
        }
Example #9
0
 public DCUser2 Save(DCUser2 dcusr)
 {
     m_uf.Save(dcusr);
     GetHeaderToken(dcusr);
     return(dcusr);
 }
Example #10
0
 public DCUser2 Get(DCUser2 dcusr)
 {
     m_uf.Get(dcusr);
     GetHeaderToken(dcusr);
     return(dcusr);
 }