本文整理汇总了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);
}
示例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!"));
}
示例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!"));
}
示例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();
}