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


C# Member.ToMembershipUser方法代码示例

本文整理汇总了C#中Member.ToMembershipUser方法的典型用法代码示例。如果您正苦于以下问题:C# Member.ToMembershipUser方法的具体用法?C# Member.ToMembershipUser怎么用?C# Member.ToMembershipUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Member的用法示例。


在下文中一共展示了Member.ToMembershipUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateUser

        ///<summary>
        ///
        ///                    Adds a new membership user to the data source.
        ///                
        ///</summary>
        ///
        ///<returns>
        ///
        ///                    A <see cref="T:System.Web.Security.MembershipUser" /> object populated with the information for the newly created user.
        ///                
        ///</returns>
        ///
        ///<param name="username">
        ///                    The user name for the new user. 
        ///                </param>
        ///<param name="password">
        ///                    The password for the new user. 
        ///                </param>
        ///<param name="email">
        ///                    The e-mail address for the new user.
        ///                </param>
        ///<param name="passwordQuestion">
        ///                    The password question for the new user.
        ///                </param>
        ///<param name="passwordAnswer">
        ///                    The password answer for the new user
        ///                </param>
        ///<param name="isApproved">
        ///                    Whether or not the new user is approved to be validated.
        ///                </param>
        ///<param name="providerUserKey">
        ///                    The unique identifier from the membership data source for the user.
        ///                </param>
        ///<param name="status">
        ///                    A <see cref="T:System.Web.Security.MembershipCreateStatus" /> enumeration value indicating whether the user was created successfully.
        ///                </param>
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            var args = new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if (RequiresUniqueEmail && GetUserNameByEmail(email) != null)
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            MembershipUser u = GetUser(username, false);

            if (u == null)
            {
                var member = new Member(username, EncodePassword(password), email, passwordQuestion, passwordAnswer, isApproved);
                this.members.Add(member);

                if (providerUserKey != null)
                {
                    if (!(providerUserKey is Guid))
                    {
                        status = MembershipCreateStatus.InvalidProviderUserKey;
                        return null;
                    }

                    member.ID = (Guid) providerUserKey;
                }

                status = MembershipCreateStatus.Success;
                return member.ToMembershipUser();
            }

            status = MembershipCreateStatus.DuplicateUserName;
            return null;
        }
开发者ID:andy-uq,项目名称:Echo,代码行数:78,代码来源:XmlMembershipProvider.cs


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