4

I want to retrieve the username of the logged-in user. Is it possible? The app is for intranet only.

1 Answer 1

6

To add Windows authentication to an app, declare the 'enterpriseAuthentication' capability in the manifest.

Refer to the info in this related question for more details.

Edit:

To retrieve the domain name of the user, I believe you can use Windows.System.UserProfile.UserInformation.GetDomainNameAsync. There is also the User domain name sample on MSDN.

4
  • I have already enabled Enterprise Authentication, Internet (Client), Private Networks (Client & Server). I'm able to open an Intranet URL in a WebView without the credential prompt. But in my XAML code, I want to retrieve the domainname\username so I can call a WebAPI which takes the username as the input and returns some user-specific data which needs to be on the tile.
    – tempid
    Oct 5, 2012 at 16:52
  • Thanks for the edit! The sample is just what I wanted. I was able to retrieve the domainname and username. Thanks Nathan!!
    – tempid
    Oct 5, 2012 at 18:08
  • The relevant code in the sample is marked as async - async void GetDNSDomain_Click(object sender, RoutedEventArgs e) as the code is using an async operation - GetPrincipalNameAsync. I wanted to retrieve the name in the OnNavigatedTo event. Is there a non-async way of retrieving it?
    – tempid
    Oct 5, 2012 at 18:13
  • See msdn.microsoft.com/en-us/library/windows/apps/hh452713.aspx for more info on working with Async methods. Oct 5, 2012 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.