Search code examples
asp.net-mvc-4active-directorywindows-authentication

Is Active Directory authentication used?


I've inherited MVC4 application. It looks like Windows Authentication is used, but I also was told that "Active Directory Authentication" is used for some permissions. I do not see anything in web.config about Active Directory. In web.config:

<authentication mode="Windows" />
   <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
         <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=21bf1234ad634e53" connectionStringName="DefaultConnection" applicationName="/" />
       </providers>
   </roleManager>

In Controller:

[Authorize(Roles = @"ABCD\EFG"), HandleError(ExceptionType = typeof(UnauthorizedAccessException), View = "UnauthorizedUser", Order = 1)]
public class HomeController : Controller
{ .............

}

public ActionResult MyAction()
{

    if (!User.IsInRole(@"ABCD\EFG"))
    {
        // some code
    }

    //.............

}

Is "Active Directory Authentication" used in this application ?

Thank you


Solution

  • The windows authentication will indeed integrate with Active Directory as long as the application server is on the domain your users are registered in.

    The below line in your config file enables such functionality.

    <authentication mode="Windows" />
    

    This post might help you get further: Configure ASP.NET MVC for authentication against AD