Beispiel #1
0
        //public static SessionInfo LogOn(string username)
        //{
        //    SessionInfo _session = new SessionInfo();
        //    if (username.ToUpper().Equals("ADMINISTRATOR"))
        //    {
        //        UserBusiness _userBusiness = new UserBusiness();
        //        _session = _userBusiness.LogOn(username);
        //    }

        //    return _session;
        //}

        public static SessionInfo LogOn(string username, string password, string userIP, int intADLogin)
        {
            UserBusiness _userBusiness = new UserBusiness();
            SessionInfo  _session      = null;
            //string currentpassword = DecodeJSPassEncoding(password);
            string currentpassword = password.Trim();

            try
            {
                if (username.ToUpper().Equals("ADMINISTRATOR"))
                {
                    string systempassword = DecodeJSPassEncoding((string)ConfigurationSettings.AppSettings[AppSettingName.SYSTEM_KEY]);
                    if (systempassword.Equals(currentpassword))
                    {
                        _session = _userBusiness.LogOn(username, userIP);
                    }
                    else
                    {
                        throw new Exception("That password is incorrect. Be sure you're using the password for your Deal Maker account.");
                    }

                    _session.IsSystemUser = true;
                }
                else
                {
                    //log on via AD user
                    bool validUser = false;
                    if (intADLogin == 1)
                    {
                        validUser = LDAPHelper.ValidateUser(username, currentpassword);
                    }
                    else
                    {
                        validUser = _userBusiness.GetAll().FirstOrDefault(p => p.USERCODE.ToLower().Equals(username.ToLower())) != null ? true : false;
                    }

                    if (validUser)
                    {
                        _session = _userBusiness.LogOn(username, userIP);
                        _session.IsSystemUser = false;
                    }
                    else
                    {
                        throw new Exception("That username is not authorized. Be sure you're using the username and password for your Windows account.");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new UIPException(ex);
            }

            return(_session);
        }
Beispiel #2
0
        public static MA_USER ValidateUser(SessionInfo sessioninfo, string strUsername, string strPassword, int intADLogin)
        {
            UserBusiness _userBusiness = new UserBusiness();

            try
            {
                bool validUser = true;
                if (intADLogin == 1)
                {
                    validUser = LDAPHelper.ValidateUser(strUsername, strPassword);
                }

                if (validUser)
                {
                    MA_USER user = _userBusiness.GetByUserCode(sessioninfo, strUsername);

                    return(user);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new UIPException(ex);
            }


            //if (strUsername == "Admin")
            //{
            //    return new { Result = "OK", Message = "" };
            //}
            //else
            //{
            //    return new { Result = "ERROR", Message = "User has no right to approve limit." };
            //}
        }