Is User Authenticated?

Discussion in 'ASP .Net' started by shapper, Dec 11, 2006.

  1. shapper

    shapper Guest

    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
     
    shapper, Dec 11, 2006
    #1
    1. Advertising

  2. 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.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "shapper" <> wrote in message
    news:...
    > 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
    >
     
    Juan T. Llibre, Dec 11, 2006
    #2
    1. Advertising

  3. shapper

    shapper Guest

    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

    Juan T. Llibre wrote:
    > 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.
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "shapper" <> wrote in message
    > news:...
    > > 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
    > >
     
    shapper, Dec 11, 2006
    #3
  4. 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.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "shapper" <> wrote in message
    news:...
    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

    Juan T. Llibre wrote:
    > 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.
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "shapper" <> wrote in message
    > news:...
    > > 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
    > >
     
    Juan T. Llibre, Dec 11, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kristofer Liljeblad

    Terminating a authenticated user

    Kristofer Liljeblad, Jun 30, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    474
    Kristofer Liljeblad
    Jun 30, 2003
  2. David Krussow
    Replies:
    2
    Views:
    649
    Richard
    Jan 17, 2005
  3. Olivier Verdin
    Replies:
    0
    Views:
    309
    Olivier Verdin
    Nov 5, 2004
  4. Benny Ng
    Replies:
    0
    Views:
    491
    Benny Ng
    Sep 19, 2005
  5. Abhijit
    Replies:
    0
    Views:
    164
    Abhijit
    Apr 12, 2004
Loading...

Share This Page