Search code examples
c#asp.net-mvc-3active-directorymembership-provider

Login to different active directories programaticly in c#


The company that I work for has two active directories (ad1.com, ad2.com) because it has two different stores that had nothing to do with each other and plenty of users but now the managers of both stores need a page in common. So I need to create a login where the users could access using just their Active Directory username and password.

In the login page there should be a list to choose the active directory and after that the user Paul(paul@ad1.com) and the user Paul(paul@ad2.com) with their respective password should be able to access to the page.

I have the code needed for the logIn page for one AD and works great but I don't know if it's possible to make the page available for two ADs. Do I need some extra configuration on the server?

I google this but didn't find anything related.


Solution

  • If you have the code required for one AD, you could very well use the same code with slight modifications to authenticate against another AD.

    Based on the domain name, you can identify the settings for AD and perform your authentication.

    In cases where you use two AD, only identifying the domain name matters E.g. ad1\username or username@ad1.com. You will not be able to achieve a login without the user specifying the domain name.