'Extend Thread.CurrentPrincipal with new property

When the user get authenticated in my Web API I set this:

Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(uname), null);

I then access the value like this:

string userName = Thread.CurrentPrincipal.Identity.Name;

This gets me the username of the user, but I would like to extend Thread.CurrentPrincipal.Identity so I also can set and get an Id like this:

Thread.CurrentPrincipal.Identity.Id

Is this possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source