Change authentication ticket value at run time?

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Change authentication ticket value at run time?

    Hi,
    what am I doing wrong ?

    there is 2 levels of user accessing the
    application:'Admin' and 'NoneAdmin'.
    I'm using role based authentication.

    some 'Admin' user need to manipulate data on behalf of
    some 'NoneAdmin' user, which means that I have an option
    where the 'Admin' user, after he is logged in, would
    view,save, update,delete other user data) and in order to
    allow this "Admin' to manipulate the 'NoneAdmin' data, I
    need to change his authentication ticket at runtime
    temporarily to let him act as the owner of this data.

    here is the code:
    Dim tempTicket As New FormsAuthenticationTicket(1,
    NoneAdmin_Name, _
    DateTime.Today,
    DateTime.Today.AddMinutes(180), _
    True, "xxxx")

    Dim hashTempTicket As String = FormsAuthentication.Encrypt
    (tempTicket)
    Dim tempCookie As HttpCookie = New HttpCookie
    (FormsAuthentication.FormsCookieName(), tempTicket)
    tempCookie.Expires = DateTime.Today.AddMinutes(60)
    Response.Cookies.Add(tempCookie)


    I suppose that this temporary ticket will overwrite the
    original one that I saved somewhere before it get
    overwritten.

    the problem is, that the next request to any page the user
    is redirected to the the login page

    thank you for any help.


    Tony Guest

  2. Similar Questions and Discussions

    1. Form Authentication Ticket
      I've read some books and online articles on how to implement form authentication. Some taught me just to do...
    2. Encryption of Authentication Ticket
      i have a question regarding the encryption of an Authentication Ticket under FormsAuthentication. Can anyone tell me what type of encryption is used...
    3. Why authentication Ticket expires
      Can anybody tells if I'm doing something wrong in this code and why the user authentication ticket always expires 30 minutes later, even though I...
    4. Authentication ticket, cookieless, forms authentication?
      Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the...
    5. Custom Authentication Ticket
      James, I found your C code and tutorial about this. I attempted to convert it to VB as follows but could you possibly tell me why the code segment...
  3. #2

    Default RE: Change authentication ticket value at run time?

    Hi Tony,

    How about SignOut the Admin user first and then assign him a noneadmin
    FormsAuthenticationTicket?

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

  4. #3

    Default RE: Change authentication ticket value at run time?

    hi Lucke,
    I tried that too (SignOut the 'Admin' then assign him a
    new ticket as 'NoneAdmin') but it keep redirecting the
    user to the login page.

    and I even tried to delete the old cookie on the client
    side (Response.cookie("cookieName")=Nothing
    Response.cookie("cookieName")="/"
    Response.cookie("cookieName").expires=new DateTime
    (19661,1) )
    but it didn't work either.

    any more idea ??
    Tony Guest

  5. #4

    Default RE: Change authentication ticket value at run time?

    Hi Tony,

    I am working on this issue to make sure if this is possible and will update
    you as soon as possible.

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

  6. #5

    Default RE: Change authentication ticket value at run time?

    Hi Tony,

    Based on my test, following code seem to be workable:

    Dim tempTicket As New FormsAuthenticationTicket(1, "NoneAdmin",
    DateTime.Now, DateTime.Now.AddMinutes(60), True, "xxxx")

    Dim hashTempTicket As String =
    FormsAuthentication.Encrypt(tempTicket)
    Dim tempCookie As HttpCookie = New
    HttpCookie(FormsAuthentication.FormsCookieName(), hashTempTicket)
    tempCookie.Expires = tempTicket.Expiration
    tempCookie.Path = FormsAuthentication.FormsCookiePath
    Response.Cookies.Add(tempCookie)


    Compared with your code, I set the cookie's Expire and Path. I put above
    code in a button's click event. In another button's CLick event, I have
    following code:

    Response.Write(User.Identity.Name)

    It output "NoneAdmin" instead of "Admin"

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139