Locking out a user in an ASP .Net Custom Membership Provider

后端 未结 4 623
别跟我提以往
别跟我提以往 2021-02-09 13:42

I\'ve had to create a custom membership provider for my current ASP .Net project in order to fit in with our database schema, and am having problems configuring it to lockout a

4条回答
  •  囚心锁ツ
    2021-02-09 13:59

    Replicate the conditions that lead to lockout (too many bad login attempts). Because Membership providers make a trip to their backend every time, it is sensible to limit this approach to providers with reasonable number of MaxInvalidPasswordAttempts.

    if (0 < Membership.MaxInvalidPasswordAttempts && Membership.MaxInvalidPasswordAttempts < 100)
           {
                    for(int i = 0; i <= Membership.MaxInvalidPasswordAttempts; i++)
                    {
                        Membership.ValidateUser(userName, "jfdlsjflksjlkfjsdlkfjsdl");
                    }
            }
    

提交回复
热议问题