Forms Authentication with AD Problem

M

Mike Green

Hi

I am creating a ASP.NET 2 applications with Forms Authentication with Active
Directory Login page.

I have created a login page, web.config file etc. exactly like the examples
in the MSDN article:-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000026.asp

Apart from one thing it all works ok.

I can log in with the correct username and password etc. no problem. If I
enter an incorrect username, it displays a message "Your login attempt was
not successful. Please try again.", which is expected.

However, if I enter a correct Username but Incorrect Password, I get a
server error (like below).

I have tried everything, but can't seem to get this to work.

Any ideas or thoughts would be much appreciated?

Many Thanks
Mike Green


Server Error in '/FormsAuthAD' Application.
----------------------------------------------------------------------------
----

A local error occurred.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.DirectoryServices.Protocols.LdapException: A local
error occurred.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[LdapException: A local error occurred.]

System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredenti
al newCredential, Boolean needSetCredential) +2050
System.DirectoryServices.Protocols.LdapConnection.Bind(NetworkCredential
newCredential) +30

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateCredentials(St
ring username, String password) +364

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUserCore(Strin
g username, String password) +1556
System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUser(String
username, String password) +34

System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(Authenti
cateEventArgs e) +100
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e)
+113
System.Web.UI.WebControls.Login.AttemptLogin() +178
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
+134
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +107
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
+178

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3837
 
J

Joe Kaplan \(MVP - ADSI\)

That's pretty interesting. Typically, I see the "a local error has
occurred" error when there is a problem with Kerberos. Is it possible there
is something funny about the DNS name you are using to connect to AD or
something? Do you see any weird events in the system or security event log
when you execute this code (from Kerberos or something else)?

Obviously, something isn't working right, but I'm guessing the issue is
something environmental in this case. You should get the same error in both
cases (which is what you are expecting).

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
Mike Green said:
Hi

I am creating a ASP.NET 2 applications with Forms Authentication with
Active
Directory Login page.

I have created a login page, web.config file etc. exactly like the
examples
in the MSDN article:-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000026.asp

Apart from one thing it all works ok.

I can log in with the correct username and password etc. no problem. If I
enter an incorrect username, it displays a message "Your login attempt was
not successful. Please try again.", which is expected.

However, if I enter a correct Username but Incorrect Password, I get a
server error (like below).

I have tried everything, but can't seem to get this to work.

Any ideas or thoughts would be much appreciated?

Many Thanks
Mike Green


Server Error in '/FormsAuthAD' Application.
----------------------------------------------------------------------------
----

A local error occurred.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.DirectoryServices.Protocols.LdapException: A
local
error occurred.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[LdapException: A local error occurred.]

System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredenti
al newCredential, Boolean needSetCredential) +2050
System.DirectoryServices.Protocols.LdapConnection.Bind(NetworkCredential
newCredential) +30

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateCredentials(St
ring username, String password) +364

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUserCore(Strin
g username, String password) +1556

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUser(String
username, String password) +34

System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(Authenti
cateEventArgs e) +100
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e)
+113
System.Web.UI.WebControls.Login.AttemptLogin() +178
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs
e)
+134
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+56
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +107
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
+178

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3837



----------------------------------------------------------------------------
 
L

lacutis

Joe said:
That's pretty interesting. Typically, I see the "a local error has
occurred" error when there is a problem with Kerberos. Is it possible there
is something funny about the DNS name you are using to connect to AD or
something? Do you see any weird events in the system or security event log
when you execute this code (from Kerberos or something else)?

Obviously, something isn't working right, but I'm guessing the issue is
something environmental in this case. You should get the same error in both
cases (which is what you are expecting).

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
Mike Green said:
Hi

I am creating a ASP.NET 2 applications with Forms Authentication with
Active
Directory Login page.

I have created a login page, web.config file etc. exactly like the
examples
in the MSDN article:-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000026.asp

Apart from one thing it all works ok.

I can log in with the correct username and password etc. no problem. If I
enter an incorrect username, it displays a message "Your login attempt was
not successful. Please try again.", which is expected.

However, if I enter a correct Username but Incorrect Password, I get a
server error (like below).

I have tried everything, but can't seem to get this to work.

Any ideas or thoughts would be much appreciated?

Many Thanks
Mike Green


Server Error in '/FormsAuthAD' Application.
----------------------------------------------------------------------------
----

A local error occurred.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.DirectoryServices.Protocols.LdapException: A
local
error occurred.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[LdapException: A local error occurred.]

System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredenti
al newCredential, Boolean needSetCredential) +2050
System.DirectoryServices.Protocols.LdapConnection.Bind(NetworkCredential
newCredential) +30

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateCredentials(St
ring username, String password) +364

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUserCore(Strin
g username, String password) +1556

System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUser(String
username, String password) +34

System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(Authenti
cateEventArgs e) +100
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e)
+113
System.Web.UI.WebControls.Login.AttemptLogin() +178
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs
e)
+134
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+56
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +107
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
+178

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3837



----------------------------------------------------------------------------

I'm having this exact same problem. The kicker is the project works
perfectly fine on an XP machine and a Windows 2003 server. It behaves
as defined on a Windows 2000 server. I've verified all the domain
settings, the LDAP connection string, etc and it all seems right. The
fact that it works 100% as expected on different machines is odd.

Ryan Roper.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top