Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am new for Active Directory authentication. Need to create login using active directory. Please help me with explained example or link where i can learn to create active directory login


C#
<authentication mode="Forms">
      <forms name=".ADAuthCookie" loginUrl="~/Account/LogOn" timeout="15" slidingExpiration="false" protection="All" />
    </authentication>
    <membership defaultprovider="MY_ADMembershipProvider">
      <providers>
        <clear />
        <add name="MY_ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionstringname="ADService" attributemapusername="sAMAccountName" />
      </providers>
    </membership>


What I have tried:

http://www.code.colostate.edu/active-directory-authentication-in-aspnet-mvc-5.aspx

http://www.benramey.com/2014/10/20/active-directory-authentication-in-asp-net-mvc-5-with-forms-authentication-and-group-based-authorization/
Posted
Updated 16-Apr-19 20:47pm
v3

1 solution

You'll want to switch from forms to windows authentication and deny anonymous users.

XML
<configuration>
  <system.web>
    <authentication mode="Windows"/>
    <authorization>
        <deny users="?"/>
    </authorization>
  </system.web>
</configuration>


This should open a login window when users access the system.

There's a comprehensive list with examples on the patterns and practices site at:
How To: Use Windows Authentication in ASP.NET 2.0[^]
 
Share this answer
 
Comments
itsathere 10-May-16 6:30am    
It's windows authentication not active directory authentication.
Nathan Minier 10-May-16 6:57am    
Windows authentication uses Active Directory just like native logins.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900