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


C# MembershipPasswordFormat.ToString方法代码示例

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


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

示例1: SqlMembershipProviderPasswordService

        /// <summary>
        /// Initializes a new <see cref="SqlMembershipProviderPasswordService"/> using the provided password format.
        /// </summary>
        /// <param name="passwordFormat">The password encryption method.</param>
        public SqlMembershipProviderPasswordService(MembershipPasswordFormat passwordFormat)
        {
            this.passwordFormat = passwordFormat;
             this.provider = new SqlMembershipProvider();

             var config = new NameValueCollection {
            { "minRequiredPasswordLength", "1" },
            { "minRequiredNonalphanumericCharacters", "0" },
            { "passwordFormat", passwordFormat.ToString() },
            { "passwordCompatMode", "Framework40" },
            { "connectionString" , "__foo__" }
             };

             this.provider.Initialize(null, config);
        }
开发者ID:rachidh,项目名称:MvcAccount,代码行数:19,代码来源:SqlMembershipProviderPasswordService.cs

示例2: CreateUserWithFormat

        private void CreateUserWithFormat(MembershipPasswordFormat format)
        {
            provider = new MySQLMembershipProvider();
            NameValueCollection config = new NameValueCollection();
            config.Add("connectionStringName", "LocalMySqlServer");
            config.Add("applicationName", "/");
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", format.ToString());
            provider.Initialize(null, config);

            // create the user
            MembershipCreateStatus status;
            provider.CreateUser("foo", "barbar!", "[email protected]", null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            // verify that the password format is hashed.
            DataTable table = FillTable("SELECT * FROM my_aspnet_Membership");
            MembershipPasswordFormat rowFormat =
                (MembershipPasswordFormat)Convert.ToInt32(table.Rows[0]["PasswordFormat"]);
            Assert.AreEqual(format, rowFormat);

            //  then attempt to verify the user
            Assert.IsTrue(provider.ValidateUser("foo", "barbar!"));
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:24,代码来源:UserManagement.cs

示例3: CreateUserWithFormat

        private void CreateUserWithFormat(MembershipPasswordFormat format)
        {
            NameValueCollection config = new NameValueCollection();
            config.Add("connectionStringName", _connStrName);
            config.Add("applicationName", _applicationName);
            config.Add("passwordStrengthRegularExpression", "bar.*");
            config.Add("passwordFormat", format.ToString());
            provider.Initialize(null, config);

            // create the user
            MembershipCreateStatus status;
            provider.CreateUser("foo", "barbar!", "[email protected]", null, null, true, null, out status);
            Assert.AreEqual(MembershipCreateStatus.Success, status);

            // verify that the password format was saved
            var user = _db.GetCollection<User>(provider.CollectionName).FindOne(Query.EQ(provider.ElementNames.LowercaseUsername, "foo"));
            MembershipPasswordFormat rowFormat = user.PasswordFormat;
            Assert.AreEqual(format, rowFormat);

            //  then attempt to verify the user
            Assert.IsTrue(provider.ValidateUser("foo", "barbar!"));
        }
开发者ID:netdragoon,项目名称:MongoProviders,代码行数:22,代码来源:MembershipProviderTest.cs

示例4: CreateUserWithFormat

        public void CreateUserWithFormat(MembershipPasswordFormat format)
        {
            var mongoProvider = new MongoMembershipProvider();
            var config = new NameValueCollection
            {
                {"connectionStringName", ConfigurationManager.ConnectionStrings[0].Name},
                {"passwordFormat", format.ToString()}
            };
            mongoProvider.Initialize("MongoMembershipProvider", config);

            // create the user
            MembershipCreateStatus status;
            var user = mongoProvider.CreateUser("foo", "barbar!", "[email protected]", null, null, true, null, out status);
            status.Should().Be(MembershipCreateStatus.Success);
            user.Should().NotBeNull();

            // verify that the password format was saved
            var collection = this.MongoDatabase.GetCollection<User>(mongoProvider.UserCollectionName);
            var userFromDB = collection.FindOneById(BsonValue.Create(user.ProviderUserKey));
            userFromDB.PasswordFormat.Should().Be(format);

            // then attempt to verify the user
            mongoProvider.ValidateUser("foo", "barbar!").Should().BeTrue();
        }
开发者ID:antonsamarsky,项目名称:e-commerce,代码行数:24,代码来源:MongoMembershipProviderTest.cs


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