Search code examples
asp.netwindows-authentication

Active Directory authentication without Login form


I want to authenticate my Users to Active Directory but without any login form.

I just want open my default page if user logged in to machine belongs to Active Directory.

Firstly, i used Windows Authentication but there is a requirement to authenticate user who belong to other domain as there are more than one domain.


Solution

  • For this, you need to use the System.DirectoryServices.AccountManagement namespace. Along with enabling Windows authentication, you need to write the authentication code in the Page_Load event of your default page. If the user is part of the required domain, authenticate him and show him the page. Otherwise, tell him that he doesn't have access.

    This answer should get you going.