Exemplo n.º 1
0
 public UserInfo()
 {
     _UserID      = -1;
     _PortalID    = -1;
     _IsSuperUser = false;
     _AffiliateID = -1;
     _Membership  = new UserMembership();
     _Profile     = new UserProfile();
 }
    protected void register_click(object sender, EventArgs e)
    {
        try
        {
            UserInfo objUser = new UserInfo();

            objUser.PortalID = customTransactions.GetPortalID(Request.ServerVariables["SERVER_NAME"].ToString());
            objUser.IsSuperUser = false;
            objUser.FirstName = txtFirstName.Text;
            objUser.LastName = txtLastName.Text;
            objUser.DisplayName = txtFirstName.Text + " " + txtLastName.Text;
            objUser.Email = txtEmailAddress.Text;
            objUser.Username = txtUserName.Text;

            UserMembership objMembership = new UserMembership(objUser);
            objMembership.Approved = true;
            objMembership.CreatedDate = DateTime.Now;
            objMembership.Email = txtEmailAddress.Text;
            objMembership.Username = txtUserName.Text;
            objMembership.Password = txtPassword.Text;

            //DotNetNuke.Security.Roles.RoleController role = new DotNetNuke.Security.Roles.RoleController();
            //role.AddUserRole(PortalAliasController.GetPortalAliasInfo(Request.ServerVariables["SERVER_NAMES"]).PortalID, objUser.UserID, 1, DateTime.Now);

            objUser.Membership = objMembership;
            UserCreateStatus result = UserController.CreateUser(ref objUser);

            //Check status
            if (result == UserCreateStatus.Success)
            {
                lblMessage.Text = "User registered successfully";
            }
            UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
            Response.Redirect("/index.aspx", false);

        }

        catch (Exception ex)
        {
            UserInfo info = UserController.GetCurrentUserInfo();
            ErrorLog objLog = new ErrorLog();
            objLog.ErrorDescription = ex.ToString();
            objLog.ErrorDate = DateTime.Now;
            objLog.ErrorFunctionName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            objLog.ErrorControlName = (GetType().ToString().Replace("ASP.", "").Replace("_ascx", ".ascx").Remove(0, GetType().ToString().Replace("ASP.", "").Replace("_ascx", ".ascx").LastIndexOf("_") + 1));
            objLog.ErrorLoggedInUser = info.Username;
            objLog.AddErrorToLog(objLog);

        }
    }
        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope CurrentScope, ref bool PropertyNotFound)
        {
            UserMembership objMembership      = objUser.Membership;
            bool           UserQueriesHimself = (objUser.UserID == AccessingUser.UserID && objUser.UserID != -1);

            if (CurrentScope < Scope.DefaultSettings || (CurrentScope == Scope.DefaultSettings && !UserQueriesHimself) ||
                ((CurrentScope != Scope.SystemMessages || objUser.IsSuperUser) &&
                 (propertyName.Equals("password", StringComparison.InvariantCultureIgnoreCase) || propertyName.Equals("passwordanswer", StringComparison.InvariantCultureIgnoreCase) || propertyName.Equals("passwordquestion", StringComparison.InvariantCultureIgnoreCase))
                ))
            {
                PropertyNotFound = true;
                return(PropertyAccess.ContentLocked);
            }
            string OutputFormat = string.Empty;

            if (format == string.Empty)
            {
                OutputFormat = "g";
            }
            switch (propertyName.ToLowerInvariant())
            {
            case "approved":
                return(PropertyAccess.Boolean2LocalizedYesNo(objMembership.Approved, formatProvider));

            case "createdondate":
                return(objMembership.CreatedDate.ToString(OutputFormat, formatProvider));

            case "isonline":
                return(PropertyAccess.Boolean2LocalizedYesNo(objMembership.IsOnLine, formatProvider));

            case "lastactivitydate":
                return(objMembership.LastActivityDate.ToString(OutputFormat, formatProvider));

            case "lastlockoutdate":
                return(objMembership.LastLockoutDate.ToString(OutputFormat, formatProvider));

            case "lastlogindate":
                return(objMembership.LastLoginDate.ToString(OutputFormat, formatProvider));

            case "lastpasswordchangedate":
                return(objMembership.LastPasswordChangeDate.ToString(OutputFormat, formatProvider));

            case "lockedout":
                return(PropertyAccess.Boolean2LocalizedYesNo(objMembership.LockedOut, formatProvider));

            case "objecthydrated":
                return(PropertyAccess.Boolean2LocalizedYesNo(true, formatProvider));

            case "password":
                return(PropertyAccess.FormatString(objMembership.Password, format));

            case "passwordanswer":
                return(PropertyAccess.FormatString(objMembership.PasswordAnswer, format));

            case "passwordquestion":
                return(PropertyAccess.FormatString(objMembership.PasswordQuestion, format));

            case "passwordresettoken":
                return(PropertyAccess.FormatString(Convert.ToString(objUser.PasswordResetToken), format));

            case "passwordresetexpiration":
                return(PropertyAccess.FormatString(objUser.PasswordResetExpiration.ToString(formatProvider), format));

            case "updatepassword":
                return(PropertyAccess.Boolean2LocalizedYesNo(objMembership.UpdatePassword, formatProvider));

            case "username":
                return(PropertyAccess.FormatString(objUser.Username, format));

            case "email":
                return(PropertyAccess.FormatString(objUser.Email, format));
            }
            return(PropertyAccess.GetObjectProperty(objMembership, propertyName, format, formatProvider, ref PropertyNotFound));
        }
Exemplo n.º 4
0
    protected void LoginBtn_Click(object sender, EventArgs e)
    {
        try
        {
            SqlConnection conn = new SqlConnection(connectionString);
            SqlDataAdapter adap = new SqlDataAdapter("Select * from Users where IsFirstLogin=0 and username= '******'", conn);
            dt.Clear();
            adap.Fill(dt);
            if (dt.Rows.Count > 0)
            {

                foreach (DataRow dr in dt.Rows)
                {
                    UserInfo objUser = new UserInfo();
                    objUser.Username = Login1.UserName;
                    UserMembership objMembership = new UserMembership(objUser);
                    objMembership.Username = Login1.UserName;
                    objMembership.Password = "******";
                    objUser.Membership = objMembership;
                    UserCreateStatus result = UserController.CreateUser(ref objUser);
                    UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
                    Response.Redirect("/profile", false);
                }
            }
            else
            {
                PortalSecurity secure = new PortalSecurity();
                if (Login1.Password != "" && Login1.UserName != "")
                {
                    UserInfo objUser = new UserInfo();
                    objUser.Username = Login1.UserName;

                    UserLoginStatus loginStatus = new UserLoginStatus();
                    UserInfo objAuthendicationPortalUserInfo = UserController.ValidateUser(0, Login1.UserName, Login1.Password, "", "", GetIPAddress(), ref loginStatus);

                    if (!(objAuthendicationPortalUserInfo == null))
                    {
                        UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
						Response.Redirect("/customredirects.aspx", false);
                    }
                    else
                    {
                        ErrorNotification = true;
                    }
                    
                }
                else
                {
                    ErrorNotification = true;
                }
            }
        }

        catch (Exception ex)
        {


            UserInfo info = UserController.GetCurrentUserInfo();
            ErrorLog objLog = new ErrorLog();
            objLog.ErrorDescription = ex.ToString();
            objLog.ErrorDate = DateTime.Now;
            objLog.ErrorFunctionName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            objLog.ErrorControlName = (GetType().ToString().Replace("ASP.", "").Replace("_ascx", ".ascx").Remove(0, GetType().ToString().Replace("ASP.", "").Replace("_ascx", ".ascx").LastIndexOf("_") + 1));
            objLog.ErrorLoggedInUser = info.Username;
            objLog.AddErrorToLog(objLog);

        }
    }
Exemplo n.º 5
-1
 public UserInfo()
 {
     _UserID = -1;
     _PortalID = -1;
     _IsSuperUser = false;
     _AffiliateID = -1;
     _Membership = new UserMembership();
     _Profile = new UserProfile();
 }