Re: AD Login failure when using ActiveDirectoryMembershipProvider
- From: Dominick Baier <dbaier@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Feb 2007 00:00:42 +0000 (UTC)
the problem is that XP is just not a realistic test environment!
to access AD you need a domain account, but ASP.NET runs under the local ASPNET account on XP. IIS6 on Windows Server 2003 behaves totally different as it uses a machine account that is a domain member when the machine gets joined to the domain (or you manually set a domain account of your choice for the worker process).
If XP is only your testing environment then you can temporarily use the <identity> element.
-----
Dominick Baier (http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
Here's my configuration:
- ASP.NET application
- Windows XP Pro running IIS
-Vdir is configured to allow anonymous access
- Anonymous access account is my domain account (for testing purposes
it's
quicker and easier to do this than to try to get another domain
account set
up)
- Web application has impersonation turned on (i.e. <identity
impersonate="true" />)
My web.config contains:
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
<providers>
<add name="AspNetActiveDirectoryMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider...
connectionStringName="ADService"
connectionProtection="Secure"
attributeMapUsername="sAMAccountName"
/>
</providers>
</membership>
With the above configuration, when I hit the following line of code I
get an exception of "Logon failure: unknown user name or bad
password."
Membership.ValidateUser( txtUsername.Text, txtPassword.Text );
If I change the web.config to the following, it works.
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
<providers>
<add name="AspNetActiveDirectoryMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider...
connectionStringName="ADService"
connectionUsername="mydomainaccount"
connectionPassword="mydomainpassword"
connectionProtection="Secure"
attributeMapUsername="sAMAccountName"
/>
</providers>
</membership>
What has me baffled is that everything I've read says that if you
don't supply the connectionUsername and connectionPassword it will use
the process identity to connect to AD. The process identity SHOULD be
my domain account, because that's the anonymous access account and
impersonation is turned on, and it obviously works when I use my
domain account credentials.
.
- Prev by Date: Re: AD Login failure when using ActiveDirectoryMembershipProvider
- Next by Date: Re: WindowsTokenRoleProvider & Domain Groups
- Previous by thread: Re: AD Login failure when using ActiveDirectoryMembershipProvider
- Next by thread: Re: AD Login failure when using ActiveDirectoryMembershipProvider
- Index(es):
Relevant Pages
|