New Posts New Posts RSS Feed: _entityManager.Principal always returns Guest
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

_entityManager.Principal always returns Guest

 Post Reply Post Reply
Author
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Topic: _entityManager.Principal always returns Guest
    Posted: 19-Aug-2010 at 5:34pm
Cool.  Thanks for letting us know!
Back to Top
madone View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Aug-2010
Location: Wisconsin
Posts: 3
Post Options Post Options   Quote madone Quote  Post ReplyReply Direct Link To This Post Posted: 18-Aug-2010 at 10:17am
I found the problem.
 
My web.config had the aspNetCompatibilityEnabled="false".  Now that I changed it to
 
<!-- Set this to true to allow use of ASP.NET security features. -->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

All is working as expected.

Back to Top
madone View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Aug-2010
Location: Wisconsin
Posts: 3
Post Options Post Options   Quote madone Quote  Post ReplyReply Direct Link To This Post Posted: 18-Aug-2010 at 5:28am
I am trying to setup my applicaton to run with Windows authentication.  Why does it always return "Guest" as the user name.  I know it's me, but, I can't figure it out.  Below is my code from mainPage.  The web config has  <authentication mode="Windows" />.
 
 
public partial class MainPage : UserControl
    {
        #region ctor & load
        public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainPage_Loaded);
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            CreateEntityManager();
            Reset();
            Login();
        }
        private void CreateEntityManager()
        {
            // create the entity manager but do not connect yet.
            _entityManager = new CollectionsEntities(false);
        }
        #endregion ctor & load
        #region login
        private void Login()
        {
            var mgr = CollectionsEntities.DefaultManager;
            mgr.LoginAsync(null, LoginCompleted, null);
        }
        private void LoginCompleted(LoginOperation args)
        {
            if (args.HasError)
            {
                txtMessages.Text = args.Error.Message + "  Web Config is probably set wrong";
                return;
            }
            UserBase user = _entityManager.Principal as UserBase;
            txtLoggedInAs.Text = user.Name;
// The user.Name is Guest # (where the # increases each time I refresh.
            if (!user.IsAuthenticated)
            {
                txtMessages.Text = " Not authenticated.";
            }
        }
        #endregion login
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down