Error in web.config with membership AD provider

て烟熏妆下的殇ゞ 提交于 2019-12-11 18:13:02

问题


Try this:

<configuration>
  <connectionStrings>
    <add name="ADService" connectionString="LDAP://mossdc02/, dc=expgroup, dc=ru" />
  </connectionStrings>
    <system.web>
        <membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
          <providers>
            <add name="AspNetActiveDirectoryMembershipProvider"
              type="System.Web.Security.ActiveDirectoryMembershipProvider, 
              System.Web, Version=2.0.3600, Culture=neutral, 
              PublicKeyToken=b03f5f7f11d50a3a"
              connectionStringName="ADService"
              connectionUsername="domain\\userName"
              connectionPassword="password"/>
          </providers>
        </membership>
        <compilation debug="true" targetFramework="4.0"/>
        <httpRuntime/>
        <authentication mode="Windows" />
      </system.web>
</configuration>

In .cs file fire this:

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) {
            string userName = "domain\\userName";
            string password = "password";

            if (Membership.Providers["AspNetActiveDirectoryMembershipProvider"].ValidateUser(userName, password)) {
                e.Authenticated = true;
            }
        }

Have this error:

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'System.Web, Version=2.0.3600, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Source Error:

Line 12: Line 13: type="System.Web.Security.ActiveDirectoryMembershipProvider, Line 15: System.Web, Version=2.0.3600, Culture=neutral, Line 16:
PublicKeyToken=b03f5f7f11d50a3a"

Help please.)


回答1:


You should not create your own ActiveDirectoryMembershipProvider, you shall only config the web.config regarding the ActiveDirectoryMembershipProvider.

<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"
       connectionUsername="testdomain\administrator" 
       connectionPassword="password"/>
  </providers>
 </membership>


来源:https://stackoverflow.com/questions/22220803/error-in-web-config-with-membership-ad-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!