Print Page | Close Window

Login Manager

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=3616
Printed Date: 04-May-2025 at 5:04pm


Topic: Login Manager
Posted By: Sakar SR
Subject: Login Manager
Date Posted: 10-Sep-2012 at 7:50am
Hello,

I am trying to develop an 2tire win forms app. when i login with LoginManager

Login Manager Code:

public class LoginManager:IEntityLoginManager
    {
        public IPrincipal Login(ILoginCredential pCredential, EntityManager pManager)
        {
            if (pCredential == null)
            {
                throw new AppLoginException(AppLoginExceptionCategory.None,MessageTypes.CreationError);
            }  
          
            IIdentity identity = new UserIdentity(pCredential.UserName, "Custom", true);
            IPrincipal principal = new UserBase(identity);          
          
            return principal;
        }

        public void Logout(IPrincipal principal,EntityManager entityManager)
        {
            SysUser aUser = SysUser.GetUser(entityManager, principal.Identity.Name);

            SysUser.LogoutUser(aUser);
        }
    }


my login code is:

private Boolean DoLogin()
        {           
            try
            {
                var credential = new LoginCredential(UserName.Text.Trim(), UserPassword.Text.Trim(), "Domain");                      
               EntityManager.DefaultManager.Login(credential);               
                return true;
            }
            catch (Exception pException)
            {               
                throw pException;
            }
        }


i am able to login , but when i try to run query on the entity like this

        private GSCostingDBEntities _lmgr = new GSCostingDBEntities();
        private BindingList<CucumberPurchaseGrade> Grades { get; set; }  

         Grades = new BindingList<CucumberPurchaseGrade>();

          var query = _lmgr.CucumberPurchaseGrades;
           var results = query.Execute();

            foreach (var item in results)
            {
                Grades.Add(item);
            }
            if(Grades.Count==0)
            {
                AddNewRec();
            }
        }


I get an error saying Unable to login . please let me know what went wrong.

Have a nice day,





Replies:
Posted By: kimj
Date Posted: 10-Sep-2012 at 10:37am
If you're using DevForce version 6.1.6 or earlier, each EntityManager must login separately as there is no single sign-on by default.   Since you're logging in the "DefaultManager", you can share its credentials with your new GSCostingDBEntities by passing the DefaultManager in the constructor or by calling LinkForAuthentication.
 
Here's more on authentication - http://drc.ideablade.com/xwiki/bin/view/Documentation/authentication-details-client - http://drc.ideablade.com/xwiki/bin/view/Documentation/authentication-details-client .


Posted By: Sakar SR
Date Posted: 10-Sep-2012 at 11:35pm
Hi kimj

Thanks for the help. i was able to solve the problem .

Have a nice day and good health





Print Page | Close Window