Ask a Question related to ASP.NET Security, Design and Development.
-
Wysiwyg #1
How do I update FormsAuthenticationTicker.userdata after ticket created?
When a user logs on to an application the new FormsAuthenticationTicket is
created with a userdata field which I can populate with anything useful I
might want. A cookie is created with an encrypted hash of the ticket.
Is it possible to update the ticket's userdata field once the ticket has
been created or is the ticket strictly readonly? If this isn't possible then
I expect I will just need to create my own cookie for additional information
that needs to change.
Thanks!
Bill
Wysiwyg Guest
-
UserData file issues
In the process of setting up a multitude of sites, we are having issues with the _mm/ct3beta/messaging/users/list/UserData.<random_string>.csi.new... -
FormsAuthenticationTicket does not return userdata
Hello, I am trying to get FormAuthentication working, but the FormsAuthenticationTicket does not return the UserData. Does any one have any... -
Manually created Cookie with UserData won't persist
I'm manually creating a FormsAuthenticationTicket and adding userdata. The problem is that the cookie won't persist. Code:... -
How do you add userdata in maya?
Does anyone know how to add userdata in Maya, I can't seem to find it in the documentation or on google? Thanks Tim -
Insert & Update triggers fire together when a new record is created.
Hi, I have two triggers, one when an insert is performed and the other when an update is performed. I use these triggers to synchronize two... -
Hernan de Lahitte #2
Re: How do I update FormsAuthenticationTicker.userdata after ticket created?
In fact, the ticket is readonly. However, you may recreate it with your new
Userdata value and update the forms cookie with the newly created ticket.
Check out this code:
// Get the cookie created by the FormsAuthentication API
// If you put this code in Application_AuthenticateRequest
// event, you may use Context.User.Identity.Name prop. instedad of
UserId.Text
HttpCookie cookie = FormsAuthentication.GetAuthCookie( UserId.Text,
false );
FormsAuthenticationTicket ticket =
FormsAuthentication.Decrypt(cookie.Value);
// Notice that all current ticket properties are preserved in the new
ticket
FormsAuthenticationTicket newticket = new FormsAuthenticationTicket(
ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration,
ticket.IsPersistent, yourNewUserDataValue, ticket.CookiePath);
// add the encrypted ticket to the cookie as data.
cookie.Value = FormsAuthentication.Encrypt(newticket);
// Update the outgoing cookies collection.
Context.Response.Cookies.Set(cookie);
Hernan de Lahitte
[url]http://weblogs.asp.net/hernandl[/url]
"Wysiwyg" <wysiwyg@xmissionNSPAM.com> wrote in message
news:cpaga9$5gb$1@news.xmission.com...> When a user logs on to an application the new FormsAuthenticationTicket is
> created with a userdata field which I can populate with anything useful I
> might want. A cookie is created with an encrypted hash of the ticket.
>
> Is it possible to update the ticket's userdata field once the ticket has
> been created or is the ticket strictly readonly? If this isn't possible
> then
> I expect I will just need to create my own cookie for additional
> information
> that needs to change.
>
> Thanks!
> Bill
>
>
Hernan de Lahitte Guest
-
Wysiwyg #3
Re: How do I update FormsAuthenticationTicker.userdata after ticket created?
Thanks for the reply! Recreating the ticket is the way to go.
Thanks again,
Bill
"Hernan de Lahitte" <hernan@lagash.com> wrote in message
news:OfuiZYk3EHA.1392@tk2msftngp13.phx.gbl...new> In fact, the ticket is readonly. However, you may recreate it with your> Userdata value and update the forms cookie with the newly created ticket.
> Check out this code:
>
> // Get the cookie created by the FormsAuthentication API
> // If you put this code in Application_AuthenticateRequest
> // event, you may use Context.User.Identity.Name prop. instedad of
> UserId.Text
> HttpCookie cookie = FormsAuthentication.GetAuthCookie( UserId.Text,
> false );
> FormsAuthenticationTicket ticket =
> FormsAuthentication.Decrypt(cookie.Value);
>
> // Notice that all current ticket properties are preserved in the new
> ticket
> FormsAuthenticationTicket newticket = new FormsAuthenticationTicket(
> ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration,
> ticket.IsPersistent, yourNewUserDataValue, ticket.CookiePath);
>
> // add the encrypted ticket to the cookie as data.
> cookie.Value = FormsAuthentication.Encrypt(newticket);
>
> // Update the outgoing cookies collection.
> Context.Response.Cookies.Set(cookie);
Wysiwyg Guest



Reply With Quote

