ASP.NET MVC form-based using AD works locally but doesn't work on server (iis7)

I implemented forms-based authentication that uses AD in an ASP MVC 3 application, following the guidelines I found here ASP.NET MVC - authenticate users in Active Directory but requires a username and password to enter

I work fine when I start using ASP.NET Development Server, but I can’t go beyond the login page after entering my credentials and gives the following error:

Configuration error

Description: An error occurred while processing the configuration file needed to service this request. Review the specific error information below and modify your configuration file accordingly.

Parser Error Message: An operational error has occurred.

Source Error:

Line 37: <membership defaultProvider="MY_ADMembershipProvider"> Line 38: <providers> Line 39: <add name="MY_ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" /> Line 40: </providers> Line 41: </membership> 

Any help would be greatly appreciated, thanks in advance.

UPDATE: Until now, after several debugs, I think that the error can occur from System.Web.Security.ActiveDirectoryMembershipProvider in the Web.xml configuration, I added System.Web (in which this class is found) as a reference, and also to create a local copies, but still, zip ... :(

+6
source share
2 answers

Make sure you have a valid username and password for an account that has sufficient privileges to request your AD:

 <add name="MY_ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" connectionUsername="YOURDOMAIN\SomeAccount" connectionPassword="secret" /> 

If you do not want to do this, you will have to configure the application pool in your IIS to run under an account that has sufficient privileges to query your Active Directory. By default, your application runs under the local NetworkService account, which does not have access to AD.

+6
source

I changed the application pool id from "ApplicationPoolIdentity" to "NetworkService" and now everything works fine.

+6
source

All Articles