New Posts New Posts RSS Feed: Anytime I use the persistancemanager, it seems to overwrite Thread.CurrentPrincipal
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Anytime I use the persistancemanager, it seems to overwrite Thread.CurrentPrincipal

 Post Reply Post Reply
Author
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Topic: Anytime I use the persistancemanager, it seems to overwrite Thread.CurrentPrincipal
    Posted: 16-Jul-2007 at 11:51am

This is intentional.

 

Creating a new PersistenceManager always causes a principal to be assigned to the currently running thread.

 

The intent is that each DevForce application begins with a login during which the LoginManager computes a principal that is assigned to the currently running thread.  The principal is determined securely by code that runs on the server.  If you do not implement a LoginManager, the null principal is assigned.

 

If you do not wish for this behavior, save the value of the principal before creating a PersistenceManager.  Then, after the value of the principal is overwritten, restore the value.

Back to Top
Customer View Drop Down
Senior Member
Senior Member
Avatar
User Submitted Questions to Support

Joined: 30-May-2007
Location: United States
Posts: 260
Post Options Post Options   Quote Customer Quote  Post ReplyReply Direct Link To This Post Posted: 16-Jul-2007 at 11:48am
Anytime I use the persistancemanager, it seems to overwrite Thread.CurrentPrincipal. I am sure it's some simple setting that I need to set. Please advise. 

Here is a sample code I am using.

MessageBox.show(System.Threading.Thread.CurrentPrincipal.Identity.Name);

PersistenceManager pm = PersistenceManager.DefaultManager;

Student student = pm.GetEntity<Student>(new PrimaryKey(typeof(Student), new Guid("e6584153-45d5-4371-8d4f-15a9e0d7f3e1")));

MessageBox.show(System.Threading.Thread.CurrentPrincipal.Identity.Name);

The two Message boxes give me following results

1) user1  (this is authenticated user's id so it's correct)

2) DefaultPrincipal - 0  (PM seems to over-write and therefore I lose my principal).

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down