|
| Webforms cookie |
 |
Wed, 2 Apr 2008 15:43:13 +0000 |
I have a few sites that required authentication through Active Directory.
Everything is working fine, but I would like to do some redirection if possible.
Right now, let's say I have this appliation /app and /app/admin
/app/admin has the admin utilities for the /app application. There is a
separate login page for each. I would like for those that are loggin into the
/app application to be redirected into the /app/admin successfully if they're
associated with a certain group.
Right now I have two different cookies. Do I need to make them the same? Here is
the code to add the cookie:
{
// Create the authetication ticketFormsAuthenticationTicket authTicket =
newFormsAuthenticationTicket(1, userName, DateTime.Now,
DateTime.Now.AddMinutes(60), false, "");
// Now encrypt the ticket.string encryptedTicket =
FormsAuthentication.Encrypt(authTicket);
// Create a cookie and add the encrypted ticket to the
// cookie as data.HttpCookie authCookie =
newHttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
// Add the cookie to the outgoing cookies
collection.HttpContext.Current.Response.Cookies.Add(authCookie);
// Redirect the user to the originally requested page
HttpContext.Current.Response.Redirect(FormsAuthentication.GetRedirectUrl(userNam
e, false));
And the web.config
<authentication mode="Forms">
<forms name="adLDSCookie" timeout="10"
path="/"/>
</authentication>
|
| Post Reply
|
|
|
|
|
|
|
|
|
|