Re: Determine auth cookies persistance programaticly?

From: P.J. Pirrello (nazghul_at_speakeasy.net)
Date: 03/31/04


Date: Wed, 31 Mar 2004 08:29:40 -0500

very cool, that's exactly what I needed. Thanks much

-PJ

"Brett Millett" <brettm73@yahoo.com> wrote in message
news:ezlsNZvFEHA.740@tk2msftngp13.phx.gbl...
> I'm using the following code in my global.asax file to kill persistant
> auth cookies for any host that is not in my network range (i.e. workers
> who take their laptops home where unauthorized people may have access to
> the laptop, for example.)
>
> protected void Application_AuthenticateRequest(Object sender, EventArgs
> e)
> {
> if (Request.IsAuthenticated)
> {
>
> IPSubNetting IP = new IPSubNetting();
> string PersistRange =
> System.Configuration.ConfigurationSettings.AppSettings["PersistRange"].T
> oString();
>
> if (!IP.IsIPNumberLocal(Request.UserHostAddress, PersistRange))
> {
> FormsIdentity id = (FormsIdentity)User.Identity;
> FormsAuthenticationTicket ticket = id.Ticket;
> if (ticket.IsPersistent)
> {
> FormsAuthentication.SignOut();
> Response.Redirect("Login.aspx", true);
> }
> }
> AttachRoles();
> }
> }
>
> basically...this is the part you need...
>
> FormsIdentity id = (FormsIdentity)User.Identity;
> FormsAuthenticationTicket ticket = id.Ticket;
> if (ticket.IsPersistent)
> {
> //...do stuff
> }
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!