Windows Authentication but Custom Authorization

Windows Authentication but Custom Authorization

Old forum URL: forums.lhotka.net/forums/t/2439.aspx


RobKraft posted on Tuesday, February 27, 2007

I feel what I am attempting should be reasonably simple but I keep getting stumped on every approach.  I would like to use Windows Authentication for my web app, but then take the Windows LogonID and map it to a Custom LogonID in a database to obtain permissions.  I created a Custom Principal and a Customer Identity (modeled after PTTracker) and I can assign them both to Csla.ApplicationContext.User.  However, they don't stay there.  Am I supposed to be able to get them to stay there?  Each time Application_AuthenticateRequest is called, the Csla.ApplicationContext.User has been replaced with WindowsIdentity and WindowsPrincipal.

My goal is to capture the user's windows logon info, then build a GenericIdentity and GenericPrincipal that I can use on server or client side anywhere within the app.  I feel I am missing something very basic.  Any guidance would be greatly appreciated.  I've spent days on trying to do this.

ajj3085 replied on Wednesday, February 28, 2007

What is your CslaAuthentication set as in your .config file?

RobKraft replied on Wednesday, February 28, 2007

Thanks for the reply.  I checked and I did not have any entry in my web.config.  However, adding the entry did not help (regardless of the value).  That led me to checking other things though and I discovered that I was missing a command like this:

HttpContext.Current.Session["CslaPrincipal"] = Csla.ApplicationContext.User;

And I think that was the source of my problem.  I also was putting code in Application_AuthenticateRequest but I needed to move it to Session_Start (not sure why yet).

Anyway, I am moving forward and I will post my results when I get all the kinks worked out.  My goal is to have an app that can use Windows or Forms Auth.  If it is Windows Auth, then the app will generate a token for the user and actually use Forms Auth.

tarekahf replied on Monday, April 14, 2008

RobKraft,

I am interested in the method you followed to use Windows Authentication and Custom Role Authorization with CSLA.

I appreciate it if you could post the details.

Regards ...

Tarek.

Copyright (c) Marimer LLC