Print Page | Close Window

Need more info for LoginAsync

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=2545
Printed Date: 22-Oct-2025 at 1:29pm


Topic: Need more info for LoginAsync
Posted By: midnit
Subject: Need more info for LoginAsync
Date Posted: 08-Mar-2011 at 4:32am
We are calling .LoginAsync and we have a simple login manager that simply creates a userbase with the credentials we pass in. It sets the name and isauthenticated=true. After the login is complete I expected that the EntityManager would then have a populated Principal but...well it does, but the name is null and isauthenticated is false.
 
So, after login:
EntityManager.IsLoggedIn = true
EntityManager.Principal.Identity.Name = null
EntityManager.Principla.Identity.IsAuthenticated = false
 

using System;
using System.Security.Principal;
using IdeaBlade.EntityModel;
using System.Runtime.Serialization;
namespace SilverlightApplication2
{
#if !SILVERLIGHT
    public class SimpleLoginManager : IEntityLoginManager
    {
    #region IEntityLoginManager Members
        public IPrincipal Login(ILoginCredential credential, EntityManager entityManager)
        {
            return new UserBase(new GenericIdentity(credential.UserName), null);
        }
        public void Logout(IPrincipal principal, EntityManager entityManager)
        {
        }
        #endregion
    }
#endif
    [DataContract]
    public class GenericIdentity : IIdentity
    {
        #region IIdentity Members
        public GenericIdentity(string name)
        {
            Name = name;
            IsAuthenticated = true;
        }
        public string AuthenticationType
        {
            get;
            internal set;
        }
        public bool IsAuthenticated
        {
            get;
            internal set;
        }
        public string Name
        {
            get;
            internal set;
        }
        #endregion
    }
}
 
So, what am I doing wrong or how are my expectations wrong?
What I want to end up with is a correctly populated Identity on the EntityManager if possible.
(I know this example doesn't handle null, its just for testing upcoming changes)
 



Replies:
Posted By: kimj
Date Posted: 08-Mar-2011 at 8:10am
I think the problem is in the GenericIdentity.  You've marked the type as a DataContract, but haven't marked any DataMembers, so the type is serialized/deserialized OK, but with default values.


Posted By: midnit
Date Posted: 08-Mar-2011 at 8:47am
Wow, thats embarrassing.
 
Thank you.



Print Page | Close Window