• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Security.MembershipUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

        public static void SendActivateEmail(MembershipUser user)
        {
            Database db = DatabaseFactory.CreateDatabase("cnGrammit");

            //Create an activation DB record with a unique GUID that
            //Use that as a request variable to the activation page
            Guid activationGuid = Guid.NewGuid();

            DbCommand dbCommand = db.GetStoredProcCommand("usp_InsertUSER_ACTIVATION");
            db.AddInParameter(dbCommand, "@userID", DbType.Guid, user.ProviderUserKey);
            db.AddInParameter(dbCommand, "@GUID", DbType.Guid, activationGuid);
            db.AddOutParameter(dbCommand, "@ID", DbType.Int32, 2);
            db.ExecuteNonQuery(dbCommand);

            StringBuilder bodyMsg = new StringBuilder();

            bodyMsg.Append("So close... <br />  in order to complete enrollment with ScoreBored.net, you'll need to confirm your account.");
            bodyMsg.AppendFormat("<br />UserName: {0}", user.UserName);
            bodyMsg.Append("<br />Password Question: " + user.PasswordQuestion);

            bodyMsg.Append("<br />Click this link to activate your account: <a href=\"");
            bodyMsg.Append(HttpRuntime.Cache.Get("basePath").ToString());

            bodyMsg.Append("Login.aspx?a=" + HttpUtility.UrlEncode(activationGuid.ToString()) + "\">ACTIVATE</a>");

            MailGen mail = new MailGen();
            mail.SendMessage(user.Email, "[email protected]", "ScoreBored Account Activation", bodyMsg.ToString());
        }
开发者ID:hobozero,项目名称:ScoreBored-NotMyCode,代码行数:28,代码来源:UserManager.cs


示例14: UserFormViewModel

 public UserFormViewModel(string[] allRoles, string[] userRoles, MembershipUser user, ViewMode mode)
 {
     AllRoles = allRoles;
     UserRoles = userRoles;
     User = user;
     Mode = mode;
 }
开发者ID:abordt,项目名称:Viking,代码行数:7,代码来源:UserFormViewModel.cs


示例15: Profile

        public Profile(string providername,
                    string UserName,
                    object ProviderUserKey,
                    string Email,
                    string PasswordQuestion,
                    string Comment,
                    bool IsApproved,
                    bool IsLockedOut,
                    DateTime CreationDate,
                    DateTime LastLoginDate,
                    DateTime LastActivityDate,
                    DateTime LastPasswordChangedDate,
                    DateTime LastLockedOutDate,
                    string RoleId,
                    string RoleName)
        {
            this.UserName = UserName;
            this.ProviderUserKey = ProviderUserKey;
            this.Email = Email;
            this.PasswordQuestion = PasswordQuestion;
            this.Comment = Comment;
            this.IsApproved = IsApproved;
            this.IsLockedOut = IsLockedOut;
            this.CreationDate = CreationDate;
            this.LastLoginDate = LastLoginDate;
            this.LastActivityDate = LastActivityDate;
            this.LastPasswordChangedDate = LastPasswordChangedDate;
            this.LastLockedOutDate = LastLockedOutDate;
            this.RoleId = RoleId;
            this.RoleName = RoleName;

            _CurrentUser = new MembershipUser("DefaultMembershipProvider", this.UserName, this.ProviderUserKey, this.Email, this.PasswordQuestion, this.Comment, this.IsApproved, this.IsLockedOut, this.CreationDate, this.LastLoginDate, this.LastActivityDate, this.LastPasswordChangedDate, this.LastLockedOutDate);
        }
开发者ID:r3plica,项目名称:Boomerang,代码行数:33,代码来源:Profile.cs


示例16: GetUsersInRole

        public static DataSet GetUsersInRole(string roleName)
        {
            DataSet ds = (DataSet)HttpContext.Current.Session["dsUsersInRole"];

            if (ds == null)
            {
                // Get all users
                MembershipUserCollection userColl = Membership.GetAllUsers();
                MembershipUser[] users = new MembershipUser[userColl.Count];
                userColl.CopyTo(users, 0);
                ds = DataSetBuilder.CreateDataSetFromBusinessObjectList(
                    users, "UserName");

                // Add check-boxes
                string[] usersInRole = Roles.GetUsersInRole(roleName);
                DataColumn col = ds.Tables[0].Columns.Add("IsInRole", typeof(bool));
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    string userName = (string)row["UserName"];
                    row["IsInRole"] = Utility.IsNameInList(userName, usersInRole);
                }

                HttpContext.Current.Session["dsUsersInRole"] = ds;
            }

            return ds;
        }
开发者ID:kiquenet,项目名称:B4F,代码行数:27,代码来源:RoleOverviewAdapter.cs


示例17: MailCustomer

 public static void MailCustomer(MembershipUser customer, string subject, string body)
 {
     // Send mail to customer
       string to = customer.Email;
       string from = BalloonShopConfiguration.CustomerServiceEmail;
       Utilities.SendMail(from, to, subject, body);
 }
开发者ID:altras,项目名称:fmi_projects,代码行数:7,代码来源:OrderProcessorMailer.cs


示例18: GetFor

 public static UserProfile GetFor(MembershipUser user)
 {
     using (DREAMContext db = new DREAMContext())
     {
         return db.UserProfiles.Find((Guid)user.ProviderUserKey);
     }
 }
开发者ID:jneufeld,项目名称:cs319,代码行数:7,代码来源:UserProfile.cs


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Security.MembershipUserCollection类代码示例发布时间:2022-05-26
下一篇:
C# Security.MembershipProvider类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap