Print Page | Close Window

Using entitymanager while authenticating

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=3686
Printed Date: 13-May-2026 at 4:45am


Topic: Using entitymanager while authenticating
Posted By: pponzano
Subject: Using entitymanager while authenticating
Date Posted: 02-Oct-2012 at 8:45am
Hello,
in my LoginManager I'm tring to verify if the user passoword has expired

I do so

  protected override bool ValidateUserCore(ILoginCredential credential)
        {
            bool res = base.ValidateUserCore(credential);

            //if (res)
            //{
            //    //Verifico che non sia scaduta la password

               
            //    EntityManager.ExecuteQuery();

            //    myModelContainer container = new myModelContainer(new EntityManagerContext(true));

            //    var user = container.aspnet_Users.FirstOrDefault(o1 => o1.UserName == credential.UserName);

            //    if (user != null)
            //    {
            //        DateTime expiryDate = DateTime.Now;
            //        if (user.USER_ACCOUNT_EXPIRY != null)
            //        {
            //            expiryDate = user.USER_ACCOUNT_EXPIRY.DATA_SCADENZA.Value;
            //        }

            //        if (expiryDate < DateTime.Now)
            //        {
            //            throw new ExpiredLoginException(expiryDate);
            //        }
            //    }

            //}

            return res;
        }

But I got an exception since the EntityManager is not authenticated, since I need to have the guest account disabled and I'm on the server during the login phase, what can I do to have access to my table?
Thanks



Replies:
Posted By: sbelini
Date Posted: 02-Oct-2012 at 11:20am
Hi,
 
I'd suggest to enable guest users and use QueryInterceptor to only allow specific entities to be accessed by these guest users.
 
sbelini.


Posted By: sbelini
Date Posted: 05-Oct-2012 at 11:37am
In addition if you actually use the EntityManager from the LoginManager, you will be able to execute queries.



Print Page | Close Window