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