views:

43

answers:

2

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?

+1  A: 

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.

Anton Gogolev
+1  A: 

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

Per Erik Stendahl