Casey ScriptFu Pharr
Casey ScriptFu Pharr

Reputation: 1680

Allowing users to log into web application using Active Directory with C#

I am trying to work out how to allow users in the company log into a web application using AD. I have looked on some sites, and the MSDN site about this, but it is not allowing me to connect. I am wondering if there is something I am missing. I am running this application on my local development machine, trying to see if the AD solution is working, but returns a server denied response. "Unable to establish secure connection with the server". I am trying to log on using my network credentials, and the domain.

Here is the web.config settings being used:

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
</authentication>
<authorization>
  <deny users="?" />
  <allow users="*" />
</authorization>
<membership defaultProvider="MyADMembershipProvider">
  <providers>
    <add
       name="MyADMembershipProvider"
       type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, 
         Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
       connectionStringName="ADConnectionString"
       connectionUsername="mydomain\username"
       connectionPassword="mypassword"/>
  </providers>
</membership>

Do I have to have something else special to setup, or should I be able to debug this locally in Visual Studio while on the network, and it will allow me to authenticate properly. Any advice or clear guidance would be greatly appreciated. This is a band new topic, so completely new to me.

Upvotes: 1

Views: 2510

Answers (1)

Tez Wingfield
Tez Wingfield

Reputation: 2251

As I mentioned in my comment you need to complete a few steps to get this to work. I have attached an image with a quick overview.

enter image description here

This will work locally but you may need to apply some changes in IIS when you upload to production environment.

Regards,

Upvotes: 2

Related Questions