Re: Changing AppDomain.CurrentDomain Principal
From: Joe Kaplan (ilearnedthisthehardway_at_noway.com)
Date: 05/22/03
- Previous message: Ramesh.N: "Registry Utitlity Issue"
- In reply to: Daren May: "Changing AppDomain.CurrentDomain Principal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 21 May 2003 23:24:24 -0500
This is interesting. I wasn't aware of this limitation. I can think of a
couple of things that might work:
- Kill the current AppDomain and start a new one. Then, restart your
application in the new AppDomain. This obviously makes things more complex
though.
- Redesign your custom principal so that you can change the identity and
roles associated with it, but leave the current instance attached.
- Set the principal on the current thread directly. This might get
complicated in a multithreaded app though. I imagine this is allowed as
ASP.NET sets the principal on each request thread to the current logged on
user, but there is only one AppDomain (normally) in a web app.
Any other ideas?
Good luck,
Joe K.
"Daren May" <daren.getrid.may@spirent.com> wrote in message
news:uEavL69HDHA.3804@tk2msftngp13.phx.gbl...
> I have managed to confuse myself trying to solve the following problem:
>
> I have an application that stores user accounts (and passwords) in a
> database. I have created custom IPrincipal and IIdentity implementations
> which seem to work fine, i.e. I can call:
>
> MyPrincipal mp = MyPrincipal.ValidateLogin(userID, password);
> AppDomain.CurrentDomain.SetThreadPrincipal(mp);
>
> MessageBox.Show("Current Principal: " +
> Thread.CurrentPrincipal.Identity.Name.ToString());
>
> Which displays the correct Name value.
>
> However, my requirements state that a user must be able to logoff and
logon
> as another account (lets avoid a debate why... I am hoarse from the
> "discussion" already... suffice to say, the requirement isn't changing).
> Now as the Help docs state, you cannot use SetThreadPrincipal more than
once
> (nice exception) and you can send a null (again, nice exception).
>
> So, I am confused on how to change the user and associated permissions.
> Should I be changing the Identity within the Principal, then reloading the
> Permissions?
>
> TIA
>
> Daren
>
>
- Previous message: Ramesh.N: "Registry Utitlity Issue"
- In reply to: Daren May: "Changing AppDomain.CurrentDomain Principal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|