New Posts New Posts RSS Feed: Login Manager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Login Manager

 Post Reply Post Reply
Author
Sakar SR View Drop Down
Newbie
Newbie
Avatar

Joined: 21-Jul-2010
Location: India
Posts: 39
Post Options Post Options   Quote Sakar SR Quote  Post ReplyReply Direct Link To This Post Topic: Login Manager
    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,


Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post 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.
 
Back to Top
Sakar SR View Drop Down
Newbie
Newbie
Avatar

Joined: 21-Jul-2010
Location: India
Posts: 39
Post Options Post Options   Quote Sakar SR Quote  Post ReplyReply Direct Link To This Post 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


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down