Hi all, First post here on asp.net. If I need to provide additional information to the problem, please let me know as this is my first attempt to authenticate against an AD server.
I have a intranet web project that I'm trying to get setup to use AD authentication. I think I have everything setup except when I run the application and try to login, I get the error "invalid username and/or password".
When I try to access an anonymously allowed controller action and try to access the membership provider, I get the following exception:
System.Configuration.ConfigurationErrorsException was unhandled Message=Could not load type 'System.Web.Providers.ActiveDirectoryMembershipProvider'.
Any thoughts on why this exception is being thrown? Any help would be greatly appreciated!
Unfortunately when I open up the project properties and look under the Web section, there is no NTLM Authentication. I am using Visual Studio 2010 with IIS Express. Any ideas?
Could you maybe post your web.config file with the membership provider and the LDAP connection string? Have you made sure that you have provided the correct defaultProvider value?
Not cocky at all; I have debugged the following controller action:
<HttpPost()> _
<AllowAnonymous()> _
<ValidateAntiForgeryToken()> _
Public Function Login(model As LoginModel, returnUrl As String) As ActionResult
If ModelState.IsValid AndAlso FormsAuthentication.Authenticate(model.UserName, model.Password) Then
Return RedirectToLocal(returnUrl)
End If
' If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The user name or password provided is incorrect.")
Return View(model)
End Function
From what I find when debugging, the "FormsAuthentication.Authenticate" method returns false. Is there perhaps something I'm missing here that I can step through to find out exactly why it's returning false?
Well for the Default Web Development Server NTLM Authentication exists, it's also possible to create a website on your local IIS and attach the project to it through VS
I guess that's better than putting all the configuration and exposing password in the web.config file and also it will be useless when you deploy it, because Windows Authentication is a part of IIS.
Regards,
Yasine
Yasine
-------------------
Mark this post, if you find it helpful.
adam.bauerle
0 Points
11 Posts
ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 19, 2012 08:51 PM|LINK
Hi all, First post here on asp.net. If I need to provide additional information to the problem, please let me know as this is my first attempt to authenticate against an AD server.
I have a intranet web project that I'm trying to get setup to use AD authentication. I think I have everything setup except when I run the application and try to login, I get the error "invalid username and/or password".
When I try to access an anonymously allowed controller action and try to access the membership provider, I get the following exception:
System.Configuration.ConfigurationErrorsException was unhandled Message=Could not load type 'System.Web.Providers.ActiveDirectoryMembershipProvider'.
Any thoughts on why this exception is being thrown? Any help would be greatly appreciated!
Adam
ryanbesko
Contributor
3561 Points
619 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 19, 2012 08:56 PM|LINK
In IIS, under your application, under the IIS section, go into Authentication. Make sure Windows Authentication is the only one enabled.
adam.bauerle
0 Points
11 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 19, 2012 11:14 PM|LINK
Hi Ryan,
Thanks for replying so soon!
Where might I check on these settings when using VS2010 and IIS Express (in development)?
Adam
lyasine
Member
162 Points
26 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 19, 2012 11:48 PM|LINK
Hello,
You shoould check on Project Properties on Section Web : NTLM Authentication.
Regards,
Yasine
-------------------
Mark this post, if you find it helpful.
adam.bauerle
0 Points
11 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 20, 2012 02:17 PM|LINK
Hi Yasine,
Unfortunately when I open up the project properties and look under the Web section, there is no NTLM Authentication. I am using Visual Studio 2010 with IIS Express. Any ideas?
Thanks for your help!
Adam
bweber89
Member
486 Points
119 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 20, 2012 02:51 PM|LINK
Hi adam
Could you maybe post your web.config file with the membership provider and the LDAP connection string? Have you made sure that you have provided the correct defaultProvider value?
Hope it helps
Cheers
Junior Software Developer
adam.bauerle
0 Points
11 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 20, 2012 03:01 PM|LINK
Hi Ben,
Thanks for your help!
Below is what I have in web.config for this project (connection credentials are **'ed out):
<add name="ADConnectionString" connectionString=LDAP://**adservername**/DC=**networkdomain** />
<membership defaultProvider="AD_MembershipProvider">
<providers>
<add name="AD_MembershipProvider" type="System.Web.Providers.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" connectionUsername="**networkdomain**\administrator" connectionPassword="**adminpwd**" />
</providers>
</membership>
Thanks!
Adam
bweber89
Member
486 Points
119 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 20, 2012 03:06 PM|LINK
Hi adam
Looks all good to me! Am not trying to be cocky, but have you debugged the logon action method?
Cheers
Junior Software Developer
adam.bauerle
0 Points
11 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 20, 2012 03:17 PM|LINK
Hi Ben,
Not cocky at all; I have debugged the following controller action:
<HttpPost()> _
<AllowAnonymous()> _
<ValidateAntiForgeryToken()> _
Public Function Login(model As LoginModel, returnUrl As String) As ActionResult
If ModelState.IsValid AndAlso FormsAuthentication.Authenticate(model.UserName, model.Password) Then
Return RedirectToLocal(returnUrl)
End If
' If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The user name or password provided is incorrect.")
Return View(model)
End Function
From what I find when debugging, the "FormsAuthentication.Authenticate" method returns false. Is there perhaps something I'm missing here that I can step through to find out exactly why it's returning false?
Thanks Ben.
lyasine
Member
162 Points
26 Posts
Re: ASP.NET MVC 4 using Active Directory for Forms Authentication
Nov 20, 2012 03:29 PM|LINK
Hi Adam,
Well for the Default Web Development Server NTLM Authentication exists, it's also possible to create a website on your local IIS and attach the project to it through VS
I guess that's better than putting all the configuration and exposing password in the web.config file and also it will be useless when you deploy it, because Windows Authentication is a part of IIS.
Regards,
Yasine
-------------------
Mark this post, if you find it helpful.