Export (0) Print
Expand All

Walkthrough: Terminate a User Session

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

This walkthrough demonstrates how to use the Security Application Block to expire a user token.

To reproduce the demonstration

  1. Authenticate the user. The following code demonstrates how to authenticate a user using the System.Web.Security.Membership class.
  2. IIdentity identity = null;
    if (Membership.ValidateUser("username", "password"))
    {
      identity = new GenericIdentity("username", Membership.Provider.Name);
    }
    
    
  3. Create the security cache by adding the following code.
  4. ISecurityCacheProvider secCache = SecurityCacheFactory.GetSecurityCacheProvider("Caching Store Provider");
    
    
  5. Call the SaveIdentity method on the security cache object by adding the following code.
  6. IToken token = null; 
    if (identity != null)
    {
      token = secCache.SaveIdentity(identity);
    }
    
    
  7. Call the ExpireIdentity method on the security cache object by adding the following code.
  8. secCache.ExpireIdentity(token);
    
    

This removes the identity information associated with the token from the cache.


Show:
© 2014 Microsoft