Is User Authenticated?

S

shapper

Hello,

I need to check if a user is authenticated. I tried everything I could
think and find:

If Membership.ValidateUser("shapper", "27lamps11") Then
Response.Write(Request.IsAuthenticated.ToString)
Response.Write(My.User.IsAuthenticated.ToString)
Response.Write(Me.User.Identity.IsAuthenticated.ToString)
Else
Response.Write("# User is Not Authenticated #")
End If

I get "FalseFalseFalse".

What is going on?

Thanks,
Miguel
 
J

Juan T. Llibre

I have already explained to you that Authentication is not the same as validating Membership.

You will *always* get False when validating Membership data
against Authenticated users, who must login with Windows credentials.
 
S

shapper

Hi Juan,

It is working now. Could you tell me if this is the right way:
If Membership.ValidateUser("username", "pass") Then
FormsAuthentication.SetAuthCookie("shapper", True)
Response.Write(Request.IsAuthenticated.ToString)
Response.Write(My.User.IsAuthenticated.ToString)
Response.Write(User.Identity.IsAuthenticated.ToString)
Else
Response.Write("# User is Not Authenticated #")
End If

And can you tell me which code line should I use to verify if a user is
authenticated:
Request.IsAuthenticated.ToString, My.User.IsAuthenticated.ToString or
User.Identity.IsAuthenticated.ToString?

Thank You,
Miguel
 
J

Juan T. Llibre

re:
And can you tell me which code line should I use to verify if a user is authenticated:
Request.IsAuthenticated.ToString, My.User.IsAuthenticated.ToString or
User.Identity.IsAuthenticated.ToString?

Which ones return valid responses ?
You can use any which return valid responses.

Remember, they will only produce valid results if you're using Forms Authentication and Membership.
They will *not* authenticate a user if you're using Windows Integrated Security.





Hi Juan,

It is working now. Could you tell me if this is the right way:
If Membership.ValidateUser("username", "pass") Then
FormsAuthentication.SetAuthCookie("shapper", True)
Response.Write(Request.IsAuthenticated.ToString)
Response.Write(My.User.IsAuthenticated.ToString)
Response.Write(User.Identity.IsAuthenticated.ToString)
Else
Response.Write("# User is Not Authenticated #")
End If

And can you tell me which code line should I use to verify if a user is
authenticated:
Request.IsAuthenticated.ToString, My.User.IsAuthenticated.ToString or
User.Identity.IsAuthenticated.ToString?

Thank You,
Miguel
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top