尝试使用AD进行表单身份验证,但缺少SimpleMembership数据库时出现app错误

时间:2014-12-12 20:45:02

标签: asp.net-mvc forms-authentication simplemembership

我有一个简单的应用程序:http://locahost/ITSuggestionBox,它将用户带到评论框,然后他们提交存储在数据库中的数据。我有另一页:... /详细信息显示该数据的表示。我添加了身份验证,以便进入该URL的用户需要针对AD进行身份验证,否则会将其重定向到登录页面。问题是,当我现在转到我的应用程序时,它被重定向到:http://localhost/ITSuggestionBox/Account/Login?ReturnUrl=%2fITSuggestionBox并抛出以下错误:

Format of the initialization string does not conform to specification starting at index 0.
Line 32:  using (var context = new UsersContext())
Line 33:  {
Line 34:    if(!context.Database.Exists())
Line 35:    {
Line 36:      // Create the SimpleMembership database without Entity Framework migration schema

Source File: c:\Dev\_MyProjects\SuggestionBox\SuggestionBox\Filters\InitializeSimpleMembershipAttribute.cs Line: 34

这是我的web.config:

<connectionStrings>
    <add name="CommentDbContext" connectionString="Data Source=DBServer;Initial Catalog=DBName;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
    <add name="ADConnectionString" connectionString="LDAP://testdomain.test.com/CN=Users,DC=testdomain,DC=test,DC=com" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"><assemblies><add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /></assemblies></compilation>
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms name="ADAuthCookie" loginUrl="~/Account/Login" timeout="15" slidingExpiration="false" protection="All" />
    </authentication>
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
    <membership defaultProvider="MY_ADMembershipProvider">
      <providers>
        <clear />
        <add name="MY_ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
      </providers>
    </membership>

该应用尝试使用SimpleMembership数据库是否有原因?我使用了很多页面,但现在似乎被卡住了:

0 个答案:

没有答案