Authenticate user through active directory (LDAP)

2019-08-06 19:34发布

问题:

I've looked around on how to do this but no luck so far. Anyone know where to start? Basically my company have active directory server and I build a site where user will use their company account to login.

I've tried Organizational Accounts option from Visual Studio Web Application but it returned Invalid domain name. Pic below

Any help will be appreciated.

回答1:

From what I understand of your question, you're looking for forms authentication via Active Directory, which would be 'Individual Accounts' in the list above.

Microsoft has a guide on how to achieve this. The guide is for ASP.NET Web Forms but should be easily transferable to MVC, just try not to overcomplicate anything.

Google searching around this area should be done with caution as it is easy to confuse Forms authentication against AD with Windows authentication against AD, and if you want to use a login form, you definitely want forms. You will likely also want to make sure that

A breakdown for the guide;

  1. Step 1

    Create a forms authentication based website.

  2. Step 2

    Override Machine.config for Forms with your Web.config

  3. Step 3

    Configure the ActiveDirectoryMembershipProvider and relevant connection strings to connect to your AD server.

  4. Step 4

    Wire it all up and apply validation to the form.

relevant link 1

relevant link 2