Need Help Understanding How To Add "Groups" Feature to Web Site
- From: pbd22 <dushkin@xxxxxxxxx>
- Date: Wed, 10 Dec 2008 07:43:56 -0800 (PST)
Hi.
Could somebody explain to me what concepts I need to read up on to
better understand how to implement "groups" on my site. I am trying to
design "group tabs" a la facebook or some such social networking
site.
As of right now, I have rolled my own authentication but, it seems
that if I want to add groups / roles and so on, I will be adding a
level of complexity that is better dealt with by adding the ASPNET
database provided with MS SQL? I am using MS SQL 2005 / VS 2008.
Along those lines, I have stumbled accross the below login code which
seems to touch on what I am trying to accomplish (add groups and
roles). Would somebody mind giving me a rough (conceptual) idea of
what is going on here and / or point me towards some good links /
online errata that discusses how to add "groups" features to web
sites?
Thanks much.
if (mySecurity.IsAuthenticated(this.txtUsername.Text,
this.txtPassword.Text, "survey"))
{
string sRoles = mySecurity.GetRoles(this.txtUsername.Text,
"survey");
// Create the authentication ticket
FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(1, // version
this.txtUsername.Text, // user name
DateTime.Now, // creation
DateTime.Now.AddMinutes(120),// Expiration
false, // Persistent
sRoles); // User data
// Now encrypt the ticket.
string encryptedTicket = FormsAuthentication.Encrypt
(authTicket);
// Create a cookie and add the encrypted ticket to the
cookie as data.
HttpCookie authCookie = new HttpCookie
(FormsAuthentication.FormsCookieName, encryptedTicket);
// Add the cookie to the outgoing cookies collection.
Response.Cookies.Add(authCookie);
// Redirect the user to the originally requested page
FormsAuthentication.RedirectFromLoginPage
(txtUsername.Text, false);
}
String cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (null == authCookie)
{
return;
}
FormsAuthenticationTicket authTicket = null;
try
{
authTicket = FormsAuthentication.Decrypt
(authCookie.Value);
}
catch (Exception ex)
{
//Write the exception to the Event Log.
return;
}
if (null == authTicket)
{//Cookie failed to decrypt.
return;
}
//When the ticket was created, the UserData property was
assigned a
//pipe-delimited string of group names.
String[] groups = authTicket.UserData.Split(new char[]
{ '|' });
//Create an Identity.
GenericIdentity id = new GenericIdentity(authTicket.Name,
"LdapAuthentication");
//This principal flows throughout the request.
GenericPrincipal principal = new GenericPrincipal(id, groups);
Context.User = principal;
.
- Prev by Date: Re: acess denied
- Next by Date: RE: Windows Server 2003 WDS
- Previous by thread: Pointer to array of strings
- Next by thread: How to cast IO Stream to StreamWriter?
- Index(es):
Relevant Pages
|