asp.net login control not authenticating?

B

bernadou

I’m using a sql2005 db created with aspnet_regsql.exe. and a simple asp.net
2.0 login control and, a passwordRecovery control on the same page. I can
connect to the db using the ASP.NET Configuration tool and add users. They
show up and everything appears OK… but….

When I attempt to use the login control, it returns the standard
“unsuccessful†error. On the same page in the password retrieval control, if
I enter the user name, it returns the appropriate security question for that
user and authenticates the answer and sends the email.

So, I suspect that something is amiss with the login control, but, I’m new
to using it, and, am not sure where to begin the troubleshooting process.

Where should I start if I know the username and password I’m entering are
correct, yet, they do not authenticate?

Thanks in advance for any assistance.
Bernie
 
B

beaudetious

Did you handle the Login Control's Authenticate method?

Here's what I did:

protected void Login1_Authenticate( object sender, AuthenticateEventArgs e )
{
if ( Membership.ValidateUser( this.Login1.UserName, this.Login1.Password ) )
{
FormsAuthentication.RedirectFromLoginPage( this.Login1.UserName,
this.Login1.RememberMeSet );
}
}

That should do it for you assuming you are using FormsAuthentication.
You'll also need to configure the <authentication> section inside of your
web.Config file.

<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="Login.aspx" timeout="1410" />
</authentication>

beaudetious
 
D

Dominick Baier [DevelopMentor]

hi,

that's not necessary - in fact - that's exactly the code that gets executed
by the login control if Authenticate is NOT handled.
 
B

beaudetious

In my overzealous effort to help out, I forgot to mention that I had to
handle the Authenticate method manually in order to redirect the
authenticated user to a specific URL based on the referring URL (admin roles
to the admin default page and non-admin roles to Default.aspx, etc.).
 
B

bernadou

Thanks for the input, I'm afraid I'm a bit lost here. I looked around for
some documentation on the login control, but, I haven't found any. Can you
point me in the right direction?

I'm looking for some way to expose what is happening behing the scenes so I
can see where it is failing. How do I find out what is being passed, and why
it would fail. It should be straight out of the box implementation. Hmmm.

B
 
B

beaudetious

Actually, I'm finding the Visual Studio 2005 Documentation to be very helpful
in these matters. You just drill down to the particular section you are
interested in (say Login Controls>Members>Events) and see what's there.
There seems to be a lot more examples and overviews than in the past and
that's really helped me out in my use of some of these new 2.0 web controls.

Also, these newsgroups and the ASP.NET forums have been a great boon to
those of us riding the wave of VS2005 and the .NET Framework 2.0. Most of
the articles out there are of the "gee look at these new controls and the
basic things we can do with 'em" variety. And, lastly, it seems that
everytime I come across a major stumbling block Scott Guthrie
(http://weblogs.asp.net/scottgu) writes a blog entry about it just in time to
help me out. It's completely coincidental but I'm not complaining.

Having said all of that, I can't see any reason off the top of my head, why
the default implementation of the LoginControl isn't working for you unless
you haven't set your configuration settings up properly. That's typically
the case I've run into lately. I'd check your steps with the documentation
or tech book you are using (WROX's Professional ASP.NET 2.0 has been
excellent for me) and keep plugging away at it.

Good luck.

beaudetious
 
B

bernadou

Dominick,
Can you shed some light on how one can begin troubleshooting this issue?
What confuses me most is how the ASP.Configuration tool seems to connect and
interact with the db just fine, and, the passwordRecovery control is getting
the correct password for the user entered, yet, the login control won't
authenticate that same user?

Thanks for any assistance you can provide,
B
 
E

EagleRed

I have found an excellent book on ASP.NET 2.0 that has really helped me get
into the subject. It is "Pro ASP.NET 2.0 in C# 2005" by Matthew MacDonald
and Mario Szpuszta, APress, ISBN 1-59059-496-7. It is quite comprehensive.
On this subject look at chapters 19-23. I got it at Barnes & Noble. If you
buy it, you may be able to download it in PDF format for free from the APress
website.
 
M

Matt Tart

I have been having the same problem also and have not found a solution.
If i find one before one gets posted here I'll let you know!
 
C

chrisnieboer

In the Login control.... If you have the OnAuthenticate event turned
on. Then the control seems to ignore it''s own Authentication
procedure. Therefore remove it from the web page and from the code
behind and Viola it works...
 
D

dreed

I would suggest two things to check. The first is the IsApproved flag
in the aspnet_membership database and make sure it is set to 1. The
second issue I found was the ApplicationID when I developed the site in
VS 2005 and tested on my development machine everything worked great
but when I moved it to an IIS server the login failed. The reason was
that when deployed it runs under a diffent ApplicationID and any users
created during development would not work.
 
W

Will Smith

Maybe this will be usefull...

I recently was dealing with a similar issue, however I placed a simple
login control on a user control and then placed the user control on my
login page. The purpose for this was that I was planning on re-using the
same login control in several places on the site, and didn't want to
have different versions of it floating around.

Anyway, the login control was not authenticating and I had no idea what
the problem was. Like you, I was able to connect to the db through the
Password Recovery control and the config tool, but could not
authenticate.

The solution to my problem was to remove the login control from the user
control and place it directly on the page. I have no idea why that would
cause a problem, but I have re-tested and it certainly does fix the
problem.
 

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,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top