我收到此错误消息
找不到指定的会员提供商
这是我的web.config设置:
<connectionStrings>
<add name="MyConnectionString" connectionString="Data Source=MyHostName;Initial Catalog=MyDB;User ID=userid;Password=*****" providerName="System.Data.SqlClient" />
<add name="ADConnectionString" connectionString="LDAP://demo.stl.local/DC=stl,DC=local"/>
</connectionStrings>
<system.web>
<customErrors defaultRedirect="~/error.aspx"/>
<siteMap defaultProvider="default">
<providers>
<clear/>
<add name="default" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" securityTrimmingEnabled="true"/>
</providers>
</siteMap>
<roleManager enabled="true" defaultProvider="SqlRoleManager">
<providers>
<add connectionStringName="MyConnectionString" applicationName="MyAppDemo" name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider"/>
</providers>
<membership defaultProvider="MyADMembershipProvider">
<providers>
<add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName"/>
</providers>
</membership>
我正在尝试使用ActiveDirectory身份验证的ASP.NET成员资格。使用AD进行身份验证工作正常,直到我添加了另一个连接字符串和roleManager。那么,这个设置有什么问题呢?
谢谢。
答案 0 :(得分:3)
角色管理器未关闭
<roleManager enabled="true" defaultProvider="SqlRoleManager">
<providers>
<add connectionStringName="MyConnectionString" applicationName="MyAppDemo" name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider"/>
</providers>
<membership defaultProvider="MyADMembershipProvider">
//here
</roleManager>
答案 1 :(得分:1)
好吧,Membership
节点与providers
处于同一级别,也许您应该在</providers>
之前使用<membership>
关闭。
此外,membership
应与roleManager
分开。
<roleManager enabled="true" defaultProvider="SqlRoleManager">
<providers>
<add connectionStringName="MyConnectionString" applicationName="MyAppDemo" name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
<membership defaultProvider="MyADMembershipProvider">
<providers>
<add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName"/>
</providers>
</membership>