1

We are implementing a website in APS.NET MVC4 which has to run on intranet. We got a requirement for windows authentication with Active Directory (LDAP). When i change the authentication mode to windows from Forms , application logging automatically without explicit username and password from login page.

How to achieve windows authentication, in which the logon page which accept the username and password and should validate? Please provide me if there are any examples...any help much appreciated.

Thanks in advance

1
  • 2
    You seem to be confused about what Windows Authentication is. Commented Feb 20, 2013 at 14:11

2 Answers 2

1

You could leave FormsAuthentication enabled and then add the following membership provider:

<connectionStrings>
    <add name="ADConnectionString" connectionString="YOUR AD CONNECTION STRING" />
</connectionStrings>

and then:

<system.web>
    <authentication mode="Forms">
        <forms loginUrl="~/Account/LogOn" />
    </authentication>
    <membership defaultProvider="MY_ADMembershipProvider">
        <providers>
            <clear />
            <add name="MY_ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
        </providers>
    </membership>
</system.web>
Sign up to request clarification or add additional context in comments.

2 Comments

No, it will be forms authentication but the authorization logic will use Active Directory to authenticate and authorize users because of the custom membership provider.
@user1952461 Windows Authentication means that it uses your windows login to authenticate against an application. They log in to their windows machine / domain and since they are authenticated that way, they don't need to log in to a website since it trusts the account.
0

The method you did already seems to be correct.

In windows authentication, you will get logged automatically if you try to load the page from the same machine. However it will ask for the windows credentials if you try to login from a different machine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.