Saturday, April 18, 2015

ASP.NET Forms Authentication with Active Directory using .NET 4.0/4.5

If you read this MSDN article on Forms Authentication with Active Directory, you will notice that still only addresses ASP.NET 2.0:

The Web.config element in fact still refers to .NET 2.0 assemblies.  Therefore, if you are using a newer version of the .NET Framework such as .NET v. 4.0 or .NET v. 4.5, then you may be wondering what the newer Web.config entry should be.

Well, it is remarkably similar to the original entry with just a change to the version information:

<membership defaultProvider="MyADMembershipProvider">




           type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"






Alternatively, you can just use the following element:

<membership defaultProvider="ADMembershipProvider">


        <clear />

        <add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" connectionUsername="testdomain\administrator" connectionPassword="password" />



That’s all you have to change!!

No comments:

Post a Comment