当前位置: 首页>>代码示例>>C#>>正文


C# Security.MembershipUser类代码示例

本文整理汇总了C#中System.Web.Security.MembershipUser的典型用法代码示例。如果您正苦于以下问题:C# MembershipUser类的具体用法?C# MembershipUser怎么用?C# MembershipUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MembershipUser类属于System.Web.Security命名空间,在下文中一共展示了MembershipUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractPasswordData

        public static Tuple<MembershipPasswordFormat, string, string> ExtractPasswordData(MembershipUser user)
        {
            MembershipPasswordFormat passwordFormat;
            string passwordSalt;
            string password;

            ConnectionStringSettings connectionString = WebConfigurationManager.ConnectionStrings["DefaultConnection"];
            using(SqlConnection conn = new SqlConnection(connectionString.ConnectionString))
            {
                using(SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT PasswordFormat, PasswordSalt, Password FROM aspnet_Membership WHERE [email protected]";
                    cmd.Parameters.AddWithValue("@UserId", user.ProviderUserKey);
                    conn.Open();
                    using(SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        if(rdr != null && rdr.Read())
                        {
                            passwordFormat = (MembershipPasswordFormat) rdr.GetInt32(0);
                            passwordSalt = rdr.GetString(1);
                            password = rdr.GetString(2);
                        }
                        else
                        {
                            throw new Exception("Error extracting current password data from the database.");
                        }
                    }
                }
            }

            return new Tuple<MembershipPasswordFormat, string, string>(passwordFormat, passwordSalt, password);
        }
开发者ID:jneufeld,项目名称:cs319,代码行数:32,代码来源:DREAMMembershipProvider.cs

示例2: CreateUser

        public override MembershipUser CreateUser(string username, string password, string email, 
            string passwordQuestion, string passwordAnswer, bool isApproved, 
            object providerUserKey, out MembershipCreateStatus status)
        {

            bool created = false;
            MembershipUser membershipUser = null;

            try
            {
                created = membershipRepository.Add(username, password, email, out providerUserKey);

                membershipUser = new MembershipUser(this.Name, username, providerUserKey,
                    email, null, null, true, true, 
                    DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today);

                if (created)
                {
                    status = MembershipCreateStatus.Success;
                }
                else
                {
                    status = MembershipCreateStatus.UserRejected;
                }

            }
            catch (Exception)
            {
                status = MembershipCreateStatus.DuplicateUserName;
            }
            

            return membershipUser;
        }
开发者ID:EdwinTauro,项目名称:Gallery.Website,代码行数:34,代码来源:FinalSqlMembershipProvider.cs

示例3: Create

        public ActionResult Create()
        {
            var Perfil = new PerfilUsuario();

            MembershipUserCollection Users = Membership.GetAllUsers();

            MembershipUser[] arr = new MembershipUser[Users.Count];

            Users.CopyTo(arr, 0);

            List<MembershipUser> Usuarios =  arr.ToList();

            List<PerfilUsuario> Perfiles = db.PerfilUsuarios.ToList();

            foreach (var item in Perfiles)
            {
                Usuarios.Remove(Membership.GetUser(item.Username));
            }

            ViewBag.Usuarios = Usuarios;

            var Sucursales = db.Sucursales.OrderBy(s => s.Nombre);

            ViewBag.Sucursales = Sucursales;

            return View(Perfil);
        }
开发者ID:JotaQA,项目名称:SeguriGasesERP,代码行数:27,代码来源:UsuariosAdminController.cs

示例4: GetUser

 public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
 {
     MembershipUser user = new MembershipUser("AgileMindProvider", "test", "test", "test",
                                 string.Empty, string.Empty, true, false, DateTime.Now, DateTime.Now,
                                 DateTime.Now, DateTime.Now, DateTime.Now);
     return user;
 }
开发者ID:kbinghamibs,项目名称:UMKC5551_Project,代码行数:7,代码来源:AgileMindMembership.cs

示例5: UserAccount

		public UserAccount(MembershipUser user)
		{
			UserName = user.UserName;
			Email = user.Email;
			PasswordQuestion = user.PasswordQuestion;
			
		}
开发者ID:damirarh,项目名称:griffin.mvccontrib,代码行数:7,代码来源:UserAccount.cs

示例6: SendPasswordEmail

        public static void SendPasswordEmail(MembershipUser user, string password, PasswordEmailType passwordEmailType)
        {
            assertExists(user);
            assertHasEmail(user);

            string body = passwordEmailTemplate.Replace("<%LoginName%>", user.UserName)
                                               .Replace("<%Password%>", password);

            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-firstTime",
                                                                   passwordEmailType == PasswordEmailType.FirstTime);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-reset",
                                                                   passwordEmailType == PasswordEmailType.Reset);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-changedByUser",
                                                                   passwordEmailType == PasswordEmailType.ChangedByUser);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-not-changedByUser",
                                                                   passwordEmailType != PasswordEmailType.ChangedByUser);

            MailMessage message = new MailMessage();

            string testRecipients = ConfigurationManager.AppSettings.Get("TestEmailRecipients");
            message.To.Add(testRecipients == null ? user.Email : testRecipients);

            message.Subject = "Your new Total Giro password";
            message.Body = body;
            message.IsBodyHtml = true;

            SmtpClient client = new SmtpClient();
            client.Send(message);
        }
开发者ID:kiquenet,项目名称:B4F,代码行数:29,代码来源:UserOverviewAdapter.cs

示例7: User

 public User(MembershipUser user)
 {
     this.UserName = user.UserName;
     ProfileBase profile = ProfileBase.Create(user.UserName);
     this.FullName = profile.GetPropertyValue("FullName") as string;
     this.Email = user.Email;
 }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:7,代码来源:UserManager.cs

示例8: UserProfileManager

        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;
        }
开发者ID:felipecsl,项目名称:dover,代码行数:27,代码来源:UserProfileManager.cs

示例9: User2UserViewModel

 private UserViewModel User2UserViewModel(MembershipUser user)
 {
     var result = new UserViewModel {Name = user != null ? user.UserName : "Unknown user"};
     if (user != null)
         result.UserId = user.ProviderUserKey is Guid ? (Guid) user.ProviderUserKey : new Guid();
     return result;
 }
开发者ID:roman-kozachenko,项目名称:StandardWebProjectTemplate,代码行数:7,代码来源:ArticleAdaptor.cs

示例10: IsResetUrlValid

        public bool IsResetUrlValid(string hash, out MembershipUser user)
        {
            user = null;
            var isValid = false;
            if (!string.IsNullOrEmpty(hash))
            {
                ResetPasswordModel link = _resetPasswordRespository.Find(hash);

                isValid = (link != null && link.ExpireDate > DateTime.Now);
                if (isValid)
                {
                    user = Membership.Provider.GetUser(link.UserName, false);

                    if (user == null)
                    {
                        string userName = Membership.GetUserNameByEmail(link.UserName);
                        user = Membership.Provider.GetUser(userName, false);
                    }

                    if (user != null && user.IsLockedOut)
                    {
                        user.UnlockUser();
                    }
                }
            }

            return isValid;
        }
开发者ID:smchristenson,项目名称:CommerceStarterKit,代码行数:28,代码来源:ResetPasswordService.cs

示例11: GetUser

        public MembershipUser GetUser(String login)
        {
            using (RoleMembershipDataContext db = new RoleMembershipDataContext())
            {
                var result = from u in db.Users where (u.Login == login) select u;

                if (result.Count() == 0)
                {
                    return null;
                }

                User dbuser = result.FirstOrDefault();
                MembershipUser user = new MembershipUser("CustomMembershipProvider",
                                                         dbuser.Login,
                                                         dbuser.UserId,
                                                         String.Empty,
                                                         String.Empty,
                                                         String.Empty,
                                                         true,
                                                         false,
                                                         dbuser.CreatedDate,
                                                         DateTime.Now,
                                                         DateTime.Now,
                                                         DateTime.Now,
                                                         DateTime.Now);

                return user;
            }
        }
开发者ID:alexkasp,项目名称:monitor,代码行数:29,代码来源:UserRepository_.cs

示例12: ChangePassword

 public void ChangePassword(MembershipUser user, string newPassword)
 {
     throw new NotImplementedException();
     //var resetPassword = user.ResetPassword();
     //if(!user.ChangePassword(resetPassword, newPassword))
     //    throw new MembershipPasswordException("Could not change password.");
 }
开发者ID:plamikcho,项目名称:MembershipStarterKit,代码行数:7,代码来源:AspNetSimpleMembershipProviderWrapper.cs

示例13: SetUpData

        public void SetUpData()
        {
            // if the test user already exists delete it
            Membership.DeleteUser("user1");

            user = Membership.CreateUser("user1", "Password1!", "[email protected]");
        }
开发者ID:jneufeld,项目名称:cs319,代码行数:7,代码来源:DREAMMembershipProviderTest.cs

示例14: EditEventViewModel

        public EditEventViewModel(string eventId)
        {
            EventId = Int32.Parse(eventId);
             		_memUser = Membership.GetUser(HttpContext.Current.User.Identity.Name);
            SiteUrl = HTTPUtils.GetFullyQualifiedApplicationPath() + "event/";

            using (var context = new DataContext())
            {
                ThisEvent = context.Events.FirstOrDefault(x => x.EventId == EventId);

                // Make sure we have a permalink set
                if (String.IsNullOrEmpty(ThisEvent.PermaLink))
                {
                    ThisEvent.PermaLink = ContentUtils.GetFormattedUrl(ThisEvent.Title);
                }

                EventCategories = context.EventCategories.Where(x => x.IsActive == true).ToList();

                UsersSelectedCategories = new List<string>();

                _thisUser = context.Users.FirstOrDefault(x => x.Username == _memUser.UserName);
            }

            // Get the admin modules that will be displayed to the user in each column
            getAdminModules();
        }
开发者ID:marciocamello,项目名称:dirigo-edge,代码行数:26,代码来源:EditEventViewModel.cs

示例15: SetupData

        public void SetupData()
        {
            // make sure the test user doesn't exist
            Membership.DeleteUser("user1");

            user = Membership.CreateUser("user1", "Password1!", "[email protected]");
        }
开发者ID:jneufeld,项目名称:cs319,代码行数:7,代码来源:PreviousPasswordTest.cs


注:本文中的System.Web.Security.MembershipUser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。