Example #1
0
        public IDictionary <string, object> GetProfileDictionary(string[] properties)
        {
            var ret = new Dictionary <string, object> ();

            int len = properties != null ? properties.Length : 0;

            if (len <= 0)
            {
                return(ret);
            }

            ProfileBase profile = HttpContext.Current.Profile;
            string      name;
            int         dot;
            object      value;

            for (int i = 0; i < len; i++)
            {
                name  = properties [i];
                dot   = name.IndexOf('.');
                value = (dot > 0) ? profile.GetProfileGroup(name.Substring(0, dot)).GetPropertyValue(name.Substring(dot + 1)) : profile.GetPropertyValue(name);
                ret.Add(name, value);
            }

            return(ret);
        }
Example #2
0
        private void UserData()
        {
            DataSet ds  = new DataSet();
            string  str = Convert.ToString(Request.QueryString["id"]);

            Database.ExecuteQuery(String.Format("select UserName, EMail from vw_aspnet_MembershipUsers where UserId='{0}'", str), ref ds, null);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                UserName.Text = ds.Tables[0].Rows[0]["UserName"].ToString();;
                Email.Text    = ds.Tables[0].Rows[0]["EMail"].ToString();
                ProfileBase pb = ProfileBase.Create(UserName.Text, false);
                UserClass   uc = (UserClass)pb.GetPropertyValue("UserData");
                UserLastName.Text     = uc.LastName;
                UserFirstName.Text    = uc.FirstName;
                UserSecondName.Text   = uc.SecondName;
                UserPosition.Text     = uc.Position;
                tbPassportSeries.Text = uc.PassportSeries;
                tbPassportNumber.Text = uc.PassportNumber;
                foreach (ListItem li in BranchDDL.Items)
                {
                    if (li.Value == uc.BranchId.ToString())
                    {
                        li.Selected = true;
                    }
                }
            }
        }
        public ActionResult Index(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                UIUserCreateStatus   status;
                IEnumerable <string> errors = Enumerable.Empty <string>();
                var result = _UIUserProvider.CreateUser(model.Username, model.Password, model.Email, null, null, true, out status, out errors);
                if (status == UIUserCreateStatus.Success)
                {
                    //Check if role exists, if it does not create it and set full permission to all pages of the site
                    SetFullAccessToRole(AdminRoleName);

                    //Add the newly created user to the role.
                    _UIRoleProvider.AddUserToRoles(result.Username, new string[] { AdminRoleName });

                    if (ProfileManager.Enabled)
                    {
                        var profile = EPiServerProfile.Wrap(ProfileBase.Create(result.Username));
                        profile.Email = model.Email;
                        profile.Save();
                    }

                    //After user creation, sign-in the user account and redirect to Episerver CMS
                    var resFromSignIn = _UISignInManager.SignIn(_UIUserProvider.Name, model.Username, model.Password);
                    if (resFromSignIn)
                    {
                        return(Redirect("/episerver/cms"));
                    }
                }
                AddErrors(errors);
            }
            // If we got this far, something failed, redisplay form
            return(View(_ViewPath, model));
        }
        public override bool ValidateUser(string username, string password)
        {
            if (!base.ValidateUser(username, password))
            {
                return(false);
            }

            // If authentication of all users are configured
            var user = Membership.GetUser(username);

            if (user == null)
            {
                return(false);
            }

            var profile = ProfileBase.Create(user.UserName);
            var license = ((DateTime)profile.GetPropertyValue("License"));

            //Licensstyrning. En licens räcker ett år. Bortser från administratörer.
            if (Roles.IsUserInRole(user.UserName, "admin") || license.AddYears(1) > DateTime.Now)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        /* Updates the phone number on file for the
         * given user.
         * @param userName: The username of the user whose
         * phonenumber should be changed.
         * @param phoneNumber: The new phone number to be
         * associated with the user.
         */
        public void updatePhoneNumber(string userName, string phoneNumber)
        {
            ProfileBase profile = ProfileBase.Create(userName, true);

            profile.SetPropertyValue("PhoneNumber", phoneNumber);
            profile.Save();
        }
Example #6
0
        public void AuthenticatedDateTime()
        {
            ProfileBase profile = ProfileBase.Create("foo", true);

            ResetAppId(profile.Providers["MySqlProfileProvider"] as MySQLProfileProvider);
            DateTime date = DateTime.Now;

            profile["BirthDate"] = date;
            profile.Save();

            SettingsPropertyCollection getProps = new SettingsPropertyCollection();
            SettingsProperty           getProp1 = new SettingsProperty("BirthDate");

            getProp1.PropertyType = typeof(DateTime);
            getProp1.SerializeAs  = SettingsSerializeAs.Xml;
            getProps.Add(getProp1);

            MySQLProfileProvider provider = InitProfileProvider();
            SettingsContext      ctx      = new SettingsContext();

            ctx.Add("IsAuthenticated", true);
            ctx.Add("UserName", "foo");

            SettingsPropertyValueCollection getValues = provider.GetPropertyValues(ctx, getProps);

            Assert.AreEqual(1, getValues.Count);
            SettingsPropertyValue getValue1 = getValues["BirthDate"];

            Assert.AreEqual(date, getValue1.PropertyValue);
        }
Example #7
0
        public ActionResult Index(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                UIUserCreateStatus   status;
                IEnumerable <string> errors = Enumerable.Empty <string>();
                var result = UIUserProvider.CreateUser(model.Username, model.Password, model.Email, null, null, true, out status, out errors);
                if (status == UIUserCreateStatus.Success)
                {
                    UIRoleProvider.CreateRole(AdminRoleName);
                    UIRoleProvider.AddUserToRoles(result.Username, new string[] { AdminRoleName });

                    if (ProfileManager.Enabled)
                    {
                        var profile = EPiServerProfile.Wrap(ProfileBase.Create(result.Username));
                        profile.Email = model.Email;
                        profile.Save();
                    }

                    AdministratorRegistrationPage.IsEnabled = false;
                    SetFullAccessToWebAdmin();
                    var resFromSignIn = UISignInManager.SignIn(UIUserProvider.Name, model.Username, model.Password);
                    if (resFromSignIn)
                    {
                        return(Redirect(UrlResolver.Current.GetUrl(ContentReference.StartPage)));
                    }
                }
                AddErrors(errors);
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #8
0
        public ActionResult Index(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var result = UiUserProvider.CreateUser(model.Username, model.Password, model.Email, null, null, true, out var status, out var errors);

            if (status == UIUserCreateStatus.Success)
            {
                UiRoleProvider.CreateRole(AdminRoleName);
                UiRoleProvider.AddUserToRoles(result.Username, new string[] { AdminRoleName });

                if (ProfileManager.Enabled)
                {
                    var profile = EPiServerProfile.Wrap(ProfileBase.Create(result.Username));
                    profile.Email = model.Email;
                    profile.Save();
                }

                AdministratorRegistrationPage.IsEnabled = false;
                SetFullAccessToWebAdmin();
                var resFromSignIn = UiSignInManager.SignIn(UiUserProvider.Name, model.Username, model.Password);
                if (resFromSignIn)
                {
                    return(Redirect("/episerver/cms"));
                }
            }
            AddErrors(errors);
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #9
0
    protected void Signup_Button_Click(object sender, EventArgs e)
    {
        var email           = Request["username"];
        var firstName       = Request["firstname"];
        var lastname        = Request["lastname"];
        var password        = Request["password"];
        var confirmPassword = Request["confirm_password"];
        var rememberMe      = Request["remember"] == "on";

        if (string.IsNullOrEmpty(password) || password != confirmPassword)
        {
            MessagePanel.Visible = true;
            Message.Text         = "Password and confirmation does not match.";
            return;
        }

        try
        {
            var         user    = Membership.CreateUser(email, password, email);
            UserProfile profile = (UserProfile)ProfileBase.Create(user.UserName);

            profile.Firstname = firstName;
            profile.Lastname  = lastname;
            profile.Save();

            Response.Cookies.Add(FormsAuthentication.GetAuthCookie(email, rememberMe));
            Response.Redirect("Breakout.aspx");
        }
        catch (Exception x)
        {
            MessagePanel.Visible = true;
            Message.Text         = x.Message;
        }
    }
    //Order: 0 gender, 1 age, 2 location, 3 occupation, 4 family, 5 financial, 6 searched

    void Awake()
    {
        profiles = new List <ProfileBase>();

        for (int i = 0; i < 120; i++)
        {
            VarRef.Tag gender   = RandTag(TagCategory.Gender);
            VarRef.Tag age      = RandTag(TagCategory.Age);
            VarRef.Tag location = RandTag(TagCategory.Location);

            VarRef.Tag occupation = RandTag(TagCategory.Occupation);
            if (age == VarRef.Tag.AgeChild && occupation == VarRef.Tag.OccEmployed)
            {
                occupation = VarRef.Tag.OccStudent;
            }
            VarRef.Tag family = RandTag(TagCategory.Family);
            if (age == VarRef.Tag.AgeChild)
            {
                family = VarRef.Tag.FamSingle;
            }
            VarRef.Tag financial = RandTag(TagCategory.Financial);
            VarRef.Tag search    = RandTag(TagCategory.Searched);
            if (age == VarRef.Tag.AgeChild && search == VarRef.Tag.SearchBusiness)
            {
                search = VarRef.Tag.SearchIndoor;
            }

            NewProfile = new ProfileBase(gender, age, location, occupation, family, financial, search);
            profiles.Add(NewProfile);
        }
    }
Example #11
0
        protected virtual IEnumerable <Claim> GetProfileClaims(string userName)
        {
            var claims = new List <Claim>();

            if (ProfileManager.Enabled)
            {
                var profile = ProfileBase.Create(userName, true);
                if (profile != null)
                {
                    foreach (SettingsProperty prop in ProfileBase.Properties)
                    {
                        object value = profile.GetPropertyValue(prop.Name);
                        if (value != null)
                        {
                            if (!string.IsNullOrWhiteSpace(value.ToString()))
                            {
                                claims.Add(new Claim(GetProfileClaimType(prop.Name.ToLowerInvariant()), value.ToString()));
                            }
                        }
                    }
                }
            }

            return(claims);
        }
Example #12
0
File: Profile.cs Project: pcstx/OA
 /// <summary>
 /// Creates a new Instance of the CS Profile. Values are editable and can be commited by calling Save();
 /// </summary>
 /// <param name="username"></param>
 public Profile(ProfileBase pb)
 {
     //Profile Base does not have any data unitl a value is first accessed.
     //So we need to store the profile base instead of SettingsPropertyValueCollection
     profilebase = pb;
     state = ProfileState.ReadWrite;
 }
        public ActionResult CreateAdmin()
        {
            string storedRoleName = "WebAdmins";
            string userName       = "******";
            string password       = "******";
            string email          = "*****@*****.**";

            var admin = _uIUserProvider.GetUser(userName);

            if (admin == null)
            {
                UIUserCreateStatus status;

                IEnumerable <string> errors = Enumerable.Empty <string>();

                _uIUserProvider.CreateUser(userName, password, email, null, null, true, out status, out errors);

                _uIRoleProvider.CreateRole(storedRoleName);

                _uIRoleProvider.AddUserToRoles(userName, new string[] { storedRoleName });

                if (ProfileManager.Enabled)
                {
                    var profile = EPiServerProfile.Wrap(ProfileBase.Create(userName));

                    profile.Email = email;
                    profile.Save();
                }
            }

            return(RedirectToAction("Index"));
        }
Example #14
0
        public ActionResult MyProfile(ProfileModel profile)
        {
            //Update member profile
            if (ModelState.IsValid)
            {
                try {
                    //Update existing user if account is not locked
                    MembershipUser member = Membership.GetUser();
                    if (member.IsLockedOut)
                    {
                        ModelState.AddModelError("", member.UserName + " account must be unlocked before updating.");
                        return(View(profile));
                    }

                    //Membership
                    member.Email = profile.Email;
                    Membership.UpdateUser(member);

                    //Profile
                    ProfileBase profileBase = System.Web.HttpContext.Current.Profile;
                    profileBase["FullName"] = profile.FullName;
                    profileBase["Company"]  = profile.Company;
                    profileBase.Save();

                    return(View(profile));
                }
                catch (Exception ex) { ModelState.AddModelError("", ex); return(View(profile)); }
            }
            else
            {
                return(View(profile));
            }
        }
Example #15
0
        static void Main(string[] args)
        {
            //Create SQLMembership Database
            Process.Start("C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\aspnet_regsql.exe", "-S (localdb)\\mssqllocaldb -A all -E -d sqldb");
            Thread.Sleep(6000);

            Membership.CreateUser("*****@*****.**", "!TestUser2!", "*****@*****.**", "Who Am I?", "The User", true, out _);;
            Membership.CreateUser("*****@*****.**", "!TestAdmin2!", "*****@*****.**", "Who am I?", "The Admin", true, out _);
            var user  = Membership.GetUser("*****@*****.**");
            var user2 = Membership.GetUser("*****@*****.**");

            var profile1 = ProfileBase.Create(user.UserName);

            profile1.SetPropertyValue("PhoneNumber", "333-333-3333");
            profile1.SetPropertyValue("FirstName", "Test");
            profile1.SetPropertyValue("LastName", "User");
            profile1.Save();

            var profile2 = ProfileBase.Create(user2.UserName);

            profile2.SetPropertyValue("PhoneNumber", "444-444-4444");
            profile2.SetPropertyValue("FirstName", "Test");
            profile2.SetPropertyValue("LastName", "Admin");
            profile2.Save();

            Roles.CreateRole("User");
            Roles.CreateRole("Admin");

            Roles.AddUserToRole(user.UserName, "User");
            Roles.AddUserToRole(user2.UserName, "Admin");


            Console.WriteLine("Users Created");
        }
    private void SaveProfile()
    {
        ProfileBase Profile = HttpContext.Current.Profile;

        Profile["MyContacts"] = this.GetContacts();
        Profile.Save();
    }
Example #17
0
        public User GetUser(string userName, bool throwOnError = true)
        {
            Guard.ArgumentNotNullOrEmpty(userName, "userName");

            return(exManager.Process(() =>
            {
                var membershipUser = Membership.GetUser(userName);
                if (membershipUser == null)
                {
                    if (throwOnError)
                    {
                        throw new InvalidOperationException(Properties.Resources.MembershipUserNotFound);
                    }
                    return null;
                }

                var attributes = profileStore.GetAttributesFor(userName, new[] { "costCenter", "manager", "displayName" });

                var user = this.container.Resolve <User>();
                user.Roles = Roles.GetRolesForUser(userName);
                user.CostCenter = attributes["costCenter"];
                user.FullName = attributes["displayName"];
                user.Manager = attributes["manager"];
                // TracingBehavior should trigger here
                user.UserName = membershipUser.UserName;

                var profile = ProfileBase.Create(userName);
                user.PreferredReimbursementMethod = string.IsNullOrEmpty(profile.GetProperty <string>("PreferredReimbursementMethod")) ?
                                                    ReimbursementMethod.NotSet :
                                                    (ReimbursementMethod)Enum.Parse(typeof(ReimbursementMethod), profile.GetProperty <string>("PreferredReimbursementMethod"));
                return user;
            },
                                     Constants.NotifyPolicy));
        }
Example #18
0
        public UserProfileManager(MembershipUser _user)
        {
            if (_user == null)
            {
                throw new ArgumentNullException("_user");
            }

            UserProfile      newProfile   = new UserProfile(_user.UserName);
            ProfileBase      userProfile  = ProfileBase.Create(_user.UserName);
            ProfileGroupBase addressGroup = userProfile.GetProfileGroup("Address");

            userProfile.Initialize(_user.UserName, true);

            newProfile.Properties.Add(new ProfileProperty("Nome", "Name", userProfile["Name"].ToString()));

            newProfile.Properties.Add(new ProfileProperty("Telefone", "Phone", addressGroup["Phone"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("CEP", "CEP", addressGroup["CEP"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Endereço", "Street", addressGroup["Street"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Bairro", "Area", addressGroup["Area"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Estado", "State", addressGroup["State"].ToString()));
            newProfile.Properties.Add(new ProfileProperty("Cidade", "City", addressGroup["City"].ToString()));

            /*newProfile.Properties.Add(new ProfileProperty("FTP: Host", "FtpHost", ftpInfoGroup["FtpHost"].ToString()));
             * newProfile.Properties.Add(new ProfileProperty("FTP: Usuário", "FtpUserName", ftpInfoGroup["FtpUserName"].ToString()));
             * newProfile.Properties.Add(new ProfileProperty("FTP: Senha", "FtpPassword", ftpInfoGroup["FtpPassword"].ToString()));*/

            this.UserProfile = newProfile;
        }
        public new ActionResult Profile(ViewModels.Account.ProfileViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                bool    update = false;
                dynamic profile;

                profile = ProfileBase.Create(Membership.GetUser().UserName);

                if (viewModel.ContactId != null && viewModel.ContactId.HasValue)
                {
                    profile.ContactId = viewModel.ContactId.Value.ToString();
                    update            = true;
                }
                else
                {
                    profile.ContactId = "";
                    update            = true;
                }

                if (!string.IsNullOrEmpty(viewModel.ExternalAppKey))
                {
                    profile.ExternalAppKey = viewModel.ExternalAppKey;
                    update = true;
                }

                if (update)
                {
                    profile.Save();
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Example #20
0
        public static object GetCurrentProfile(string propertyName)
        {
            var         user       = Employee.CurrentUserName;
            ProfileBase objProfile = ProfileBase.Create(user);

            return(objProfile.GetPropertyValue(propertyName));
        }
Example #21
0
        public static UserInfoModel GetUserByName(string username)
        {
            ProfileBase objProfile = ProfileBase.Create(username);

            var email       = Membership.GetUser(username).Email;
            var roleid      = CH.GetAllData <EmployeeRole>(w => w.AccountName == username).Select(s => s.RoleID).FirstOrDefault();
            var gender      = objProfile.GetPropertyValue("Gender") as string;
            var displayName = objProfile.GetPropertyValue("DisplayName") as string;
            var mobile      = objProfile.GetPropertyValue("Mobile") as string;
            int con         = 0;

            Int32.TryParse(objProfile.GetPropertyValue("Contact").ToString(), out con);
            var      contact      = con;
            var      departmentid = objProfile.GetPropertyValue("DepartmentID") as int?;
            var      startDate    = objProfile.GetPropertyValue("StartDate") as string;
            DateTime date;

            DateTime.TryParse(startDate, out date);
            var userinfo = new UserInfoModel()
            {
                RoleID       = roleid.Value,
                Email        = email,
                Contact      = contact,
                StartDate    = date,
                Mobile       = mobile,
                Gender       = gender,
                DisplayName  = displayName,
                DepartmentID = departmentid,
                UserName     = username
            };

            return(userinfo);
        }
Example #22
0
        public ActionResult Details(string name)
        {
            if (Employee.IsEqualToCurrentUserName(name))
            {
                return(RedirectToAction("UpdateProfile", "account", new { name = name }));
            }

            var membershipuser = Membership.GetUser(name);

            var um = new UserInfoModel();

            um.UserName = membershipuser.UserName;
            um.Email    = membershipuser.Email;

            ProfileBase objProfile = ProfileBase.Create(membershipuser.UserName);
            DateTime    b;
            object      data = null;

            data = objProfile.GetPropertyValue("BirthDay");
            DateTime.TryParse(data.ToString(), out b);
            um.BirthDay = b;
            int contact = 0;

            Int32.TryParse(objProfile.GetPropertyValue("Contact").ToString(), out contact);
            um.Contact     = contact;
            um.Mobile      = objProfile.GetPropertyValue("Mobile") as string;
            um.Gender      = objProfile.GetPropertyValue("Gender") as string;
            um.DisplayName = objProfile.GetPropertyValue("DisplayName") as string;
            int roleid;

            data = objProfile.GetPropertyValue("RoleLevelID");
            Int32.TryParse(data.ToString(), out roleid);
            um.RoleID = roleid;
            return(View(um));
        }
Example #23
0
        public ActionResult Edit(EditUserModel user, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                User actualUser = user.Save(_memberShipFactory);
                if (ProfileManager.Enabled)
                {
                    ProfileBase profile = ProfileBase.Create(actualUser.LoginId, true);

                    IEnumerator properites = ProfileBase.Properties.GetEnumerator();
                    if (properites != null)
                    {
                        while (properites.MoveNext())
                        {
                            var    property = properites.Current as SettingsProperty;
                            string v        = collection[property.Name];
                            profile[property.Name] = v;
                        }
                        profile.Save();
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
Example #24
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            IIdentity      id       = User.Identity;
            dynamic        profile  = ProfileBase.Create(id.Name);
            string         username = id.Name;
            MembershipUser m        = Membership.GetUser(id.Name);

            string password         = context.Employees.Where(x => x.UserName == username).Select(x => x.Password).First();
            string encryptedPwInput = FormsAuthentication.HashPasswordForStoringInConfigFile(tbxCurrentPw.Text, "MD5");

            try
            {
                if (encryptedPwInput == password)
                {
                    if (tbxNewPw.Text != "")
                    {
                        m.ChangePassword(m.ResetPassword(), tbxNewPw.Text);
                    }
                    Employee emp = context.Employees.Where(x => x.UserName == username).First();
                    emp.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(tbxNewPw.Text, "MD5");

                    context.SaveChanges();
                    Response.Redirect("~/Admin/ReportList.aspx");
                }
            }

            catch (Exception ex)
            {
                Response.Write(ex);
                lblError.Text = "Error! Password hasn't been changed.";
            }
        }
Example #25
0
        public void AuthenticatedStringProperty()
        {
            ProfileBase profile = ProfileBase.Create("foo", true);

            ResetAppId(profile.Providers["MySqlProfileProvider"] as MySQLProfileProvider);
            profile["Name"] = "Fred Flintstone";
            profile.Save();

            SettingsPropertyCollection getProps = new SettingsPropertyCollection();
            SettingsProperty           getProp1 = new SettingsProperty("Name");

            getProp1.PropertyType = typeof(String);
            getProps.Add(getProp1);

            MySQLProfileProvider provider = InitProfileProvider();
            SettingsContext      ctx      = new SettingsContext();

            ctx.Add("IsAuthenticated", true);
            ctx.Add("UserName", "foo");

            SettingsPropertyValueCollection getValues = provider.GetPropertyValues(ctx, getProps);

            Assert.AreEqual(1, getValues.Count);
            SettingsPropertyValue getValue1 = getValues["Name"];

            Assert.AreEqual("Fred Flintstone", getValue1.PropertyValue);
        }
Example #26
0
        public IEnumerable <Claim> GetClaims(IClaimsPrincipal principal, RequestDetails requestDetails)
        {
            var userName = principal.Identity.Name;
            var claims   = new List <Claim>();

            // email address
            string email = Membership.FindUsersByName(userName)[userName].Email;

            if (!String.IsNullOrEmpty(email))
            {
                claims.Add(new Claim(ClaimTypes.Email, email));
            }

            // roles
            GetRolesForToken(userName).ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role)));

            // profile claims
            if (ProfileManager.Enabled)
            {
                var profile = ProfileBase.Create(userName, true);
                if (profile != null)
                {
                    foreach (SettingsProperty prop in ProfileBase.Properties)
                    {
                        string value = profile.GetPropertyValue(prop.Name).ToString();
                        if (!String.IsNullOrWhiteSpace(value))
                        {
                            claims.Add(new Claim(ProfileClaimPrefix + prop.Name.ToLowerInvariant(), value));
                        }
                    }
                }
            }

            return(claims);
        }
Example #27
0
        public void GetAllProfiles()
        {
            ProfileBase profile = ProfileBase.Create("foo", true);

            ResetAppId(profile.Providers["MySqlProfileProvider"] as MySQLProfileProvider);
            profile["Name"] = "Fred Flintstone";
            profile.Save();

            SettingsPropertyCollection getProps = new SettingsPropertyCollection();
            SettingsProperty           getProp1 = new SettingsProperty("Name");

            getProp1.PropertyType = typeof(String);
            getProps.Add(getProp1);

            MySQLProfileProvider provider = InitProfileProvider();
            SettingsContext      ctx      = new SettingsContext();

            ctx.Add("IsAuthenticated", true);
            ctx.Add("UserName", "foo");

            int total;
            ProfileInfoCollection profiles = provider.GetAllProfiles(
                ProfileAuthenticationOption.All, 0, 10, out total);

            Assert.AreEqual(1, total);
        }
Example #28
0
        protected void BindGrid()
        {
            //EmployeesGrid.DataSource = DataProvider.Employees.ToList();
            //EmployeesGrid.FilterExpression = OwnerPage.FilterBag.GetExpression(false);
            //EmployeesGrid.DataBind();

            _BaslangicTarihi = OwnerPage.BaslangicTarihi;
            _BitisTarihi     = OwnerPage.BitisTarihi;
            ProfileBase curProfile = ProfileBase.Create(Membership.GetUser().UserName);
            string      BayiID     = curProfile.GetPropertyValue("BayiID").ToString();

            if (Roles.GetRolesForUser(Membership.GetUser().UserName)[0].ToString() == "PersonelYonetici" ||
                Roles.GetRolesForUser(Membership.GetUser().UserName)[0].ToString() == "PersonelTeknik" ||
                Roles.GetRolesForUser(Membership.GetUser().UserName)[0].ToString() == "TemsilciYonetici" ||
                Roles.GetRolesForUser(Membership.GetUser().UserName)[0].ToString() == "DeveloperUser" ||
                Roles.GetRolesForUser(Membership.GetUser().UserName)[0].ToString() == "Muhasebe") //if ile vdm personel yönetici yetkisi için roles dan kontrol edip -1 göndermek lazım.
            {
                if (BayiID == null || BayiID == "" || BayiID == "130" || BayiID == "140")
                {
                    BayiID = "-1";
                }
            }
            var list = db.S_HedefSatisDurumu(Convert.ToInt32(BayiID), _BaslangicTarihi, _BitisTarihi).ToList();

            if (list.Count > 0)
            {
                EmployeesGrid.DataSource = list;
                EmployeesGrid.DataBind();
            }
            else
            {
                EmployeesGrid.DataSource = null;
                EmployeesGrid.DataBind();
            }
        }
Example #29
0
        public void EditUser(RegistrationData user, string password = "")
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            MembershipUser membershipUser = Membership.GetUser(user.UserName);

            if (password != "")
            {
                String resetPwd = membershipUser.ResetPassword();
                membershipUser.ChangePassword(resetPwd, password);
            }

            if (Roles.RoleExists(user.Role))
            {
                foreach (var role in Roles.GetRolesForUser(user.UserName))
                {
                    Roles.RemoveUserFromRole(user.UserName, role);
                }
                Roles.AddUserToRole(user.UserName, user.Role);
            }

            // Set the friendly name (profile setting).
            // This will fail if the web.config is configured incorrectly.
            ProfileBase profile = ProfileBase.Create(user.UserName, false);

            profile.SetPropertyValue("FriendlyName", user.FriendlyName);
            profile.SetPropertyValue("Foundry", user.Foundry);
            profile.SetPropertyValue("CustomerCompany", user.CustomerCompany);
            profile.Save();
        }
Example #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IIdentity id       = User.Identity;
            dynamic   profile  = ProfileBase.Create(id.Name);
            string    username = id.Name;

            gvResult.DataSource = (from x in context.QuizResults
                                   from y in context.Quizs
                                   where x.Username == username
                                   where x.QuizId == y.QuizId
                                   select new
            {
                ResultId = x.ResultId,
                QuizId = x.QuizId,
                Name = y.Name,
                TimeSubmitted = x.TimeSubmitted,
                Result = x.Result
            }).ToList();
            gvResult.DataBind();

            if (gvResult.Rows.Count <= 0)
            {
                lblNoResult.Text = "No results available.";
            }
            else
            {
                lblNoResult.Visible = false;
            }
        }
Example #31
0
        public void CreateUser(RegistrationData user,
                               [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))]
                               string password)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            // NOTE: ASP.NET by default uses SQL Server Express to create the user database.
            // CreateUser will fail if you do not have SQL Server Express installed.
            Membership.CreateUser(user.UserName, password);

            // Assign the user to the default role if the given role does not exist
            // This will fail if role management is disabled.
            if (Roles.RoleExists(user.Role))
            {
                Roles.AddUserToRole(user.UserName, user.Role);
            }
            else
            {
                Roles.AddUserToRole(user.UserName, UserRegistrationService.DefaultRole);
            }

            // Set the friendly name (profile setting).
            // This will fail if the web.config is configured incorrectly.
            ProfileBase profile = ProfileBase.Create(user.UserName, false);

            profile.SetPropertyValue("FriendlyName", user.FriendlyName);
            profile.SetPropertyValue("Foundry", user.Foundry);
            profile.SetPropertyValue("CustomerCompany", user.CustomerCompany);
            profile.Save();
        }
Example #32
0
File: User.cs Project: pcstx/OA
 public User(MembershipUser mu, ProfileBase pb)
     : this(mu,new Profile(pb))
 {
 }
	public void Init(ProfileBase parent, string myName) {}