System.Web.Helpers.Crypto.VerifyHashedPassword passwordFormat =“Clear”

时间:2015-02-18 21:19:07

标签: authentication sqlmembershipprovider

我最终想要使用这个示例:How to do Active Directory authentication in Razor (cshtml)来实现身份验证 - 但首先我需要我的应用程序才能使用表单身份验证。

我使用Starter Site表单WebMatrix作为示例,我认为我被困在密码的哈希上。

在我的数据库表中,密码列只填充了文本“pIg1et!”因为我只关心用户名在列表中 - 密码的实际验证将针对Active Directory完成。

create table webpages_Membership (
UserID int, 
CreateDate datetime default NULL,
ConfirmationTokin varchar(128) default NULL,
IsConfirmed int default 0,
LastPasswordFailureDate datetime default null,
PasswordFailuresSinceLastSuccess int default 0,
[Password] varchar(128),
PasswordChangeDate datetime default null,
PasswordSalt varchar(128) default null,
PasswordVerificationToken varchar(128) default null,
PasswordVerificationTokenExpirationDate datetime default null
);
go

delete from webpages_Membership;

insert into webpages_Membership select distinct teacherid, getdate(), null, 1, null, 0, 'pIg1et!', null, null, null, null from IC_ADO;

在服务器上 - 在此文件中: C:\ WINDOWS \ Microsoft.NET \ Framework64 \ v4.0.30319 \ CONFIG \ machine.config中
我有以下内容:

<system.web>

    <membership>
        <providers>
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="STUDENT" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
        </providers>
    </membership>

最初将passwordFormat设置为“Hashed”。

在iisreeset之后我希望在我登录时不会出现这个错误:

    Line 14:     if(IsPost && !Request["myusername"].IsEmpty() ){
    Line 15: 
    Line 16:         if (WebSecurity.Login(myusername, "pIg1et!", true))
    Line 17:         {
    Line 18:             Response.Redirect("~/Academic");

    [FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. ]
       System.Convert.FromBase64String(String s) +0
       System.Web.Helpers.Crypto.VerifyHashedPassword(String hashedPassword, String password) +55
       WebMatrix.WebData.SimpleMembershipProvider.CheckPassword(IDatabase db, Int32 userId, String password) +48
       WebMatrix.WebData.SimpleMembershipProvider.ValidateUser(String username, String password) +202
       WebMatrix.WebData.WebSecurity.Login(String userName, String password, Boolean persistCookie) +83
       ASP._Page_Account_Login_cshtml.Execute() in c:\inetpub\wwwroot\Academic\Account\Login.cshtml:16
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
       System.Web.WebPages.WebPage.ExecutePageHierarchy() +339
       System.Web.WebPages.StartPage.ExecutePageHierarchy() +143
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +181
       System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +207

我希望通过将passwordFormat设置为“Clear”将我放入WebSecurity.Login(___,“pIg1et!”,true)中的字符串对我的DB中的密码列正常工作,该列也具有以下值“pIg1et!”

这里发生了什么?

谢谢! 莫利

0 个答案:

没有答案