Pergunta

Currently i'm using the following code to get my custom MembershipUser, with my custom membershipprovider:

FormsIdentity id = (FormsIdentity)User.Identity;
HtCustomUser user = (HtCustomUser) Membership.GetUser(id.Ticket.Name, true);

I would like to override the parameterless GetUser() in my custom MembershipProvider, but can't figure out how to get the currently logged in user, from my provider. Currently I have overridden the GetUser(Username) and creates the custom MembershipUser, with data from my data store.

Foi útil?

Solução

As always it is alot easier finding the answer, after a question has been asked:

ServiceSecurityContext.Current.PrimaryIdentity.Name

Allows me to get the username, directly from the provider, without having to use the client User-object.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top