Using Security Application Block! I am lost I think

Topics: Security Application Block
Dec 3, 2009 at 11:28 PM

Hello I am using Security Application block in a winform Application. In my application I am using .NET MEMBERSHIP class and using the default Membership  database with the help of (aspnet_regsql.exe). Things worked good upto the varification of a username and password in the loginForm. Now after successfully verifying the username in my login form I want to get this authenticated user Token in the my other Application forms. Now I am lost here that how can I achieve this. I mean when I am executing the below code in my other application forms it is working, which I dont like or may be this is the way to do it...

            ISecurityCacheProvider secureCache = SecurityCacheFactory.GetSecurityCacheProvider("Caching Store Provider");
            userToken = CacheFactory.GetCacheManager();            
            IToken token = PropertyLoader.AuthenticatedUserToken;
            if (token != null)
                IIdentity savedIdentity = secureCache.GetIdentity(token);

                this.Text = savedIdentity.Name;

Now here I am using a static PropertyLoader.AuthenticatedUserToken and first saving the authenticated token in a static field in the login form and then retrieving it here in another form of my application. Can anybody please help me out...that how can I eliminate this satic field and can directly get the authenticated token from the block. Do I need to cache Application Block ... may be I am lost....

Thanks and regards


Dec 4, 2009 at 3:51 AM

This shows how to obtain a token - which I think you've come cross already.  As you can see, you would still need to known the user corresponding to the token you need if you want to obtain it directly from the security block.

The best way I could think of is to cache (using Caching Application Block) the IToken object right after the user has been validated.

If you don't like caching, I can only think of passing that IToken to all winforms where you will need it (which I also think is not very nice). 


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

Dec 4, 2009 at 5:02 AM

Thanks alot friend,

I will dig caching application block.  You are right, I should cache the IToken object after validation and then use it inside the application instead of using the static properties..


Thanks and regards