Print Page | Close Window

Accessing data before login

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=1800
Printed Date: 21-Apr-2026 at 12:19pm


Topic: Accessing data before login
Posted By: orcities
Subject: Accessing data before login
Date Posted: 10-May-2010 at 12:10pm
During my login process I want to access some additional data. I want to present this data on the login screen. How would I go about doing that. I have tried the below but it comes back with null ref exception:
 
EntityManager man = EntityManager.DefaultEntityManager;
System.Type t = IdeaBlade.Core.InternalFns.GetIdeaBladeType("IdeaBlade.EntityModel.Edm.EdmKey", true);
_connectionString = t.GetProperty("DbConnectionString").GetValue(man.DataSourceResolver.GetDataSourceKey("EntityManager"), null) as String;
 
Error:
Target does not match target type;.
 
Casting to an object isn't the issue. I thing it is the GetResourceKey value that is returned.
 
Any help would be great.



Replies:
Posted By: ting
Date Posted: 10-May-2010 at 6:24pm

One idea is to create a Guest account and login with the EntityManager on that account before the actual user login.  You can query for pre-login data on the guest account and restrict its access on the server using the IEntityServerSaving and IEntityServerQuerying interfaces.



Posted By: kimj
Date Posted: 10-May-2010 at 7:46pm
The exception is occurring because GetDataSourceKey returns a ClientEdmKey, not the EdmKey type on which the DbConnectionString property is defined.   There is a constructor for the EdmKey which takes a ClientEdmKey, but unless your application is 2-tier, you generally don't want to set up a requirement for the IdeaBlade.EntityModel.Edm assembly, which is logically "server side" only.


Posted By: orcities
Date Posted: 11-May-2010 at 8:09am
So would you suggest the other Guest account or what would you suggest? And it is 2-tier.


Posted By: orcities
Date Posted: 11-May-2010 at 11:17am
What assembly is the IEntityServerSaving interface under. I can not seem to find it. I have tried core, entitymodel and validation.


Posted By: stephenmcd1
Date Posted: 11-May-2010 at 11:40am
Originally posted by orcities

What assembly is the IEntityServerSaving interface under. I can not seem to find it. I have tried core, entitymodel and validation.
 
The IEntityServerSaving interface was how it was done in DevForce 2009.  In 2010, they moved to the EntityServerQueryInterceptor and EntityServerSaveInterceptor classes.   They are both in the IdeaBlade.EntityModel.Server assembly.
 
You can read about them in the Business Object Persistence.pdf help file. 
 
Hope that helps!


Posted By: stephenmcd1
Date Posted: 11-May-2010 at 11:45am
Originally posted by orcities

So would you suggest the other Guest account or what would you suggest? And it is 2-tier.
 
For what it's worth, in our application, we implemented a Guest account (like you, it's used during the logon process) and it's seemed to work well.  We have a server-side "white-list" of specific tables and stored procedures that are allowed to be used by the Guest account and any attempt to access any other tables/stored procedures/PassthruEsql, etc. raises an Exception.


Posted By: orcities
Date Posted: 11-May-2010 at 12:20pm

the docs talk about it but don't show any examples of how to use it.



Posted By: orcities
Date Posted: 17-May-2010 at 2:58pm
For anyone following. To get the same functionality I had in the my Classic version. I used the EntityServerQueryInterceptor.ClientCanQuery and ClientCanSave. If the principal was administrator I passed if not I called a static method, using reflection, for the class type (either CanQuery or CanSave) if the method didn't exist then I passed. If it did exist then I evaluated and returned the result.
 
I needed the functionality at an entity level not global level. Each entity had different permissions based on many different roles.



Print Page | Close Window