PrimeTSS
PrimeTSS

Reputation: 2713

ASP .Net Set Logged in user

I have an .net web application where I am authenticating a user through another means as well as using a login form.

when the user logs in through the "other means" I want to be able to find the user in the membership DB using the MembershipProfider.Finduser() and if they exist (ie they passed the external auth means and also exist int he DB so they can login) If all this is tru, I want to then tell .net "this" is the current user.

How do I SET the current user?

Upvotes: 1

Views: 480

Answers (2)

Per Erik Stendahl
Per Erik Stendahl

Reputation: 883

I assume you're using FormsAuthentication? Have a look at FormsAuthentication.RedirectFromLoginPage() and FormsAuthentication.SetAuthCookie().

Upvotes: 1

Anton Gogolev
Anton Gogolev

Reputation: 115749

I guess setting Thread.CurrentThread.CurrentPrincipal will do the job. You might also want to create your own implementations of IPrincipal and IIdentity, although this is not strictly neccessary.

Upvotes: 1

Related Questions