Need Help Understanding How To Add "Groups" Feature to Web Site



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;
.



Relevant Pages

  • Re: Changing windows passwords remotely
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... > //Create the ticket, and add the groups. ... > String encryptedTicket = FormsAuthentication.Encrypt; ... > //Create a cookie, and then add the encrypted ticket to the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Changing windows passwords remotely
    ... > //Create the ticket, and add the groups. ... > DateTime.Now, DateTime.Now.AddMinutes, isCookiePersistent, ... > String encryptedTicket = FormsAuthentication.Encrypt; ... > //Create a cookie, and then add the encrypted ticket to the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Changing windows passwords remotely
    ... about how to proceed or a web resource that dicusses the subject. ... //Create the ticket, and add the groups. ... String encryptedTicket = FormsAuthentication.Encrypt; ... //Create a cookie, and then add the encrypted ticket to the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Non persistent cookie timeout?
    ... > How do i get the cookie to time out after a period of inactivity, ... > If I close the browser, the next time I use the application, it makes ... > // Now encrypt the ticket. ... > string encryptedTicket = FormsAuthentication.Encrypt; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Perplexing and critical error - please help!
    ... The site uses Forms authentication w/ anonymous ... pass information about the current conference. ... FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( ... // "true" for a durable user cookie ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)