#Support Active Directory/Windows Authentication
##Windows Authentication
In some cases, it is preferable to use a custom authentication system to store all authentication data, user lists, credentials, etc. But sometimes it will be much easier to use built-in system authentication features that you are already leveraging instead of creating something new. ASP.NET can handle the authentication processes and all that is required is to apply needed roles/permissions/security rules for the user as described in our Security Guide.
Follow these steps to set up Windows Authentication with Impersonation for the AdHoc application:
##Open the Authentication settings for the website
- Open IIS Manager
- Expand the "Sites" tree and find your website
- At the Features panel, find the IIS section and click on the Authentication icon

##Configure Authentication settings
- Disable Anonymous Authentication
- Enable ASP.NET Impersonation
- Enable Windows Authentication
Or you can also set these settings manually in the web.config file at the root folder of the website. You will need to place the following settings inside the <system.web> section of your web.config:
<authentication mode="Windows" />
<identity impersonate="true" />
##Use authentication information in the AdHoc security model
Place the following lines of code into your global.asax.
C♯
Imports System.Security.Principal;
/*
implementation code
*/
public static void InitializeReporting()
{
WindowsIdentity user = WindowsIdentity.GetCurrent();
AdHocSettings.CurrentUserName = user.Name;
AdHocSettings.CurrentUserIsAdmin = new WindowsPrincipal(user).IsInRole(WindowsBuiltInRole.Administrator);
}
VB.NET
Using System.Security.Principal
'implementation code
Public Shared Sub InitializeReporting()
Dim user As WindowsIdentity = WindowsIdentity.GetCurrent()
AdHocSettings.CurrentUserName = user.Name
AdHocSettings.CurrentUserIsAdmin = New WindowsPrincipal(user).IsInRole(WindowsBuiltInRole.Administrator)
End Sub
