You try something like this.
HttpCookie cookie = Response.Cookie s[FormsAuthentica tion.FormsCooki eName];
FormsAuthentica tionTicket ticket = FormsAuthentica tion.Decrypt(co okie.Value);
You could also access specific tickets user in a HttpModule by hooking
and using an interface IHttpModule.
You will also need to add a refereance to web.config for your HttpModule.
Good Luck
public class FormsAuthSessio nEnforcement : IHttpModule
{
private static string _provider = "FiPort_Members hipProvider";
public FormsAuthSessio nEnforcement() { }
public void Init(HttpApplic ation context)
{
context.PostAut henticateReques t += new
EventHandler(On PostAuthenticat e);
}
private void OnPostAuthentic ate(Object sender, EventArgs e)
{
HttpApplication app = (HttpApplicatio n)sender;
HttpContext context = app.Context;
//If the user was authenticated with Forms Authentication
//Then check the session ID.
if (context.User.I dentity.IsAuthe nticated == true)
{
if (context.User.I sInRole("Servic eProviders"))
{
_provider = "FiPort_Members hipProviderEx";
}
FormsAuthentica tionTicket authTicket =
((FormsIdentity )context.User.I dentity).Ticket ;
Guid guid = new Guid(authTicket .UserData);
MembershipUser loginUser =
Membership.Prov iders[_provider].GetUser(authTi cket.Name, false);
Guid currentSession;
//If there isn't any session information in Membership at
this point
//then it is likely the user logged out, and an old cookie is
//being replayed.
if (!String.IsNull OrEmpty(loginUs er.Comment))
{
string currentSessionS tring =
loginUser.Comme nt.Split("|".To CharArray())[1];
currentSession = new
Guid(currentSes sionString.Spli t(";".ToCharArr ay())[1]);
}
else
{
currentSession = Guid.Empty;
}
//If the session in the cookie does not match the current
session as stored
//in the Membership database, then terminate this request
if (guid != currentSession)
{
FormsAuthentica tion.SignOut();
FormsAuthentica tion.RedirectTo LoginPage();
}
}
}
public void Dispose() { }
}
"JT**********@g mail.com" wrote:
Hi,
Does any one knows how to list all FormsAuthentica tionTicket available
on a server?
Thanks