Print Page | Close Window

Anonymous Identity Returned

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3136
Printed Date: 13-May-2026 at 1:59pm


Topic: Anonymous Identity Returned
Posted By: Vincent
Subject: Anonymous Identity Returned
Date Posted: 09-Dec-2011 at 12:55am

 

Hi everybody

 

In my Silverlight application, I am implementing IEntityLoginManager to control users’ access. Sometime the 'EntityManager.Principal.Identity.Name' returns anonymous value even when a user logs in successfully with correct user name and password.

 

Can any one help me to ensure that a correct value is returned from ‘EntityManager.Principal.Identity.Name’ when a user successfully logs in?

 

Best Regards,

Vincent

 

 




Replies:
Posted By: kimj
Date Posted: 09-Dec-2011 at 11:58am
Currently, every client-side EntityManager must login to be authorized before it can execute queries or make other service calls.    Because of this the EntityManager will always do an implicit login, even if you don't call Login (or LoginAsync) explicitly.  If your login manager allows for empty or null credentials then that could explain how an anonymous login was done.  The EntityManager.Principal will always be the one returned from the IEntityLoginManager.
 
If you construct multiple EntityManagers within your application, you can share credentials among them.  There are several ways to do this: use the EntityManager copy constructor; use the EM.LinkForAuthentication method; or implement IAuthenticationManager.
 


Posted By: Vincent
Date Posted: 09-Dec-2011 at 7:59pm
Hi Kimj
 
Thank you for the reply. Basical in my implementation of IEntityLoginManager if I do not allow null credentials, then the application fires an exception when it starts and this happens before a user logs in.
 
Can you please, give me a simple sample code showing how to prevent null credentials without having the application firing exception?
 
 
 
Best Regards,
Vincent


Posted By: kimj
Date Posted: 12-Dec-2011 at 11:05am
Hi Vincent,
 
If your application was built using one of the "Business Application Templates" it will do an automatic login with a null credential when the application starts.  This is done to "load" any currently logged in user, or for a persistent cookie.  If you don't want to support this feature you can turn it off by removing the code in the Application_Startup method in app.xaml.cs which calls AuthenticationManager.Current.LoadUser.
 
If your application wasn't built using the BAT, then check your client-side code for any EntityManager constructions.  If you have multiple EntityManagers in your code but only explicitly login on one of them, any others will pass null credentials to the login manager when they login.



Print Page | Close Window