Changing AppDomain.CurrentDomain Principal

From: Daren May (daren.getrid.may_at_spirent.com)
Date: 05/21/03


Date: Wed, 21 May 2003 14:18:36 -0700


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



Relevant Pages

  • Re: Exception Handling and Refactoring Question ...
    ... >> You have confused the type being thrown with the type being caught. ... > I didn't confuse anything. ... You said "Just derive all of your exception ... catch phrase modifies it there can be no side effects. ...
    (comp.lang.cpp)
  • Re: Oh no, the apostrophes gone!
    ... exception, Queen Anne's County, MD.)http://news.yahoo.com/s/ap/20090131/ap_on_re_eu/eu_britain_no_apostro ... ... O'Fallon, Illinois. ... That must confuse people in St. Louis that they ...
    (misc.transport.road)
  • Re: [NPP] Identify - reordering items in your pack
    ... You could certainly program in an exception for staves, wands, etc., but it would confuse the way things were sorted within a category and confuse the code required to get to absorb_item. ...
    (rec.games.roguelike.angband)