private void SaveUser(User user)
 {
     HttpContext.Current.Session["PROFILES_USER"] = user;
 }
 public void GetUserProxies(Int32 UserID)
 {
     Login.Utilities.DataIO oDataIO = new Login.Utilities.DataIO();
     System.Data.DataTable dt = new System.Data.DataTable();
     oDataIO.GetUserProxies(dt, UserID, 0, "N", "Y", "Y", "Y");
     User thisUser = new User();
     foreach (System.Data.DataRow dr in dt.Rows) {
         Proxie newProxy = new Proxie("");
         newProxy.Proxy = Convert.ToInt32(dr[0]);
         thisUser.Proxies.Add(newProxy);
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool LogIn(string username, string password)
        {
            bool rtn = false;
            try
            {
                Framework.Utilities.SessionManagement sessionmanagement = new Framework.Utilities.SessionManagement();
                User user = new User();

                Framework.Utilities.Session session = sessionmanagement.Session();
                user.UserName = username;

                //ZAP - need to do an MD5 Hash on the password
                user.Password = password;

                Login.Utilities.DataIO dataio = new Login.Utilities.DataIO();
                dataio.UserLogin(ref user, ref session);

                if (user.Roles != null)
                {
                    rtn = true;
                }

                this.SaveUser(user);

            }
            catch (Exception ex)
            {
                //ZAP- need an error log.
                ex = ex;
                rtn = false;
            }

            //ZAP-  need to cross this bridge soon
            //Find out if they have a profile
            //If they have a profile Get the users proxies

            return rtn;
        }
        public User GetUserDetails(string UserID)
        {
            Login.Utilities.DataIO oDataIO = new Login.Utilities.DataIO();
            User thisUser = new User();
            SqlDataReader dbreader = oDataIO.GetUserDetails(UserID);
            dbreader.Read();
            thisUser.PersonID = dbreader["PersonID"].ToString();
            thisUser.UserID = (Int32)dbreader["UserID"];
            thisUser.IsActive = dbreader["IsActive"].ToString();
            thisUser.CanBeProxy = dbreader["CanBeProxy"].ToString();
            thisUser.FirstName = dbreader["FirstName"].ToString();
            thisUser.LastName = dbreader["LastName"].ToString();
            thisUser.DisplayName = dbreader["DisplayName"].ToString();
            thisUser.OfficePhone = dbreader["OfficePhone"].ToString();
            thisUser.EmailAddr = dbreader["EmailAddr"].ToString();
            thisUser.InstitutionFullName = dbreader["InstitutionFullName"].ToString();
            thisUser.DepartmentFullName = dbreader["DepartmentFullName"].ToString();
            thisUser.DivisionFullName = dbreader["DivisionFullName"].ToString();
            thisUser.UserName = dbreader["UserName"].ToString();
            thisUser.Password = dbreader["Password"].ToString();
            thisUser.PasswordFormat = dbreader["PasswordFormat"].ToString();
            thisUser.PasswordQuestion = dbreader["PasswordQuestion"].ToString();
            thisUser.PasswordAnswer = dbreader["PasswordAnswer"].ToString();
            thisUser.InternalUserName = dbreader["InternalUserName"].ToString();
            thisUser.InternalLDAPUserName = dbreader["InternalLDAPUserName"].ToString();

            if (!dbreader.IsClosed)
                dbreader.Close();

            return thisUser;
        }