New Posts New Posts RSS Feed: Login while Disconnected
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Login while Disconnected

 Post Reply Post Reply
Author
mlens View Drop Down
Newbie
Newbie
Avatar

Joined: 19-Apr-2010
Location: Australia
Posts: 7
Post Options Post Options   Quote mlens Quote  Post ReplyReply Direct Link To This Post Topic: Login while Disconnected
    Posted: 25-May-2010 at 10:44pm
Hi there,

VS2008
Silverlight 3

We've implemented IEntityLoginManager which works as expected while connected. Problem is we need to provide a login mechanism for users when disconnected. What we were hoping to achieve was;

1. Attempt to login Asychronously
2. If login fails due to being disconnected, attempt to authenticate the user credentials against Entity Manager cache. (The manager is loaded at startup with an IsolatedStorageFile if it exists).

Problem is, once you implement IEntityLoginManager, you can no longer query the cache unless first logged in? (We think)

Is there a way to work disconnected once IEntityLoginManager is implemented?

Thanks
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 26-May-2010 at 2:06pm
It is the EntityServer to which you are denied access if not logged in. You can query the cache.
Back to Top
mlens View Drop Down
Newbie
Newbie
Avatar

Joined: 19-Apr-2010
Location: Australia
Posts: 7
Post Options Post Options   Quote mlens Quote  Post ReplyReply Direct Link To This Post Posted: 26-May-2010 at 4:11pm
Thanks Greg for the answer. That is what I thought I was doing with the following statements;

            IEntityQuery<User> qry = _manager.Users.Where(u => u.LogonName == LoginName);
            qry.QueryStrategy = QueryStrategy.CacheOnly;
            IEnumerable users = qry.Execute();

However, users only returns records when the application has successfully logged on.

Am I querying the cache incorrectly?

Regards
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 28-May-2010 at 12:56pm
mlens:

Are you sure you have some User entities in the cache when you run your query?

i just tested a cache-only query using the following method (having previously saved some Employees to the Data.bin file):


    private void TestLoginManager(){
      _mgr.CacheStateManager.RestoreCacheState("Data.bin");
      List<Employee> employees = _mgr.Employees.With(QueryStrategy.CacheOnly).ToList();
      // List<Employee> employees = _mgr.Employees.ToList();
      Console.WriteLine("Retrieved {0} Employees from cache", employees.Count);
      //_mgr.CacheStateManager.SaveCacheState("Data.bin");
      PromptToContinue();
    }


LoginManagerRequired was set to true in the exe project's app.config. LoginManager as follows:


  class LoginManager:IEntityLoginManager {
    #region IEntityLoginManager Members

    public System.Security.Principal.IPrincipal Login(ILoginCredential credential, EntityManager entityManager) {
      throw new NotImplementedException();
      //return new WindowsPrincipal(WindowsIdentity.GetCurrent());
    }

    public void Logout(System.Security.Principal.IPrincipal principal, EntityManager entityManager) {
      throw new NotImplementedException();
    }

    #endregion
  }


Login() is called in this LoginManager if DevForce tries to access the EntityServer.  (You can verify this by substituting the version of the query with no call to With(QueryStrategy.CacheOnly).  It throws an exception.)

The above test method, in the form shown, successfully reports 9 Employees in the list.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down