2

Some code to get the username of the logged in user on a Windows 8 store app:

var x = Windows.System.UserProfile.UserInformation;
var y = x.getPrincipalNameAsync().done(function(response) {
  console.log(response);
});

I have two VMs, Windows 8 and Windows 8.1. The code works on the solution on the Windows 8 VM, and today I followed this guide to re-target my application to Windows 8.1. And while the re-targeting worked and I can deploy the upgraded .appx to a 8.1 tablet, the code above just returns "".

Please help.

1 Answer 1

6

From the documentation:

Only domain users have a principal name. Access to the principal name can be blocked by privacy settings (for example, if the UserInformation::NameAccessAllowed property is false). If access is blocked, this method returns an empty string.

So maybe your user is nto a domain user or the privacy on your windows8 machine is different from the other one.

To make sure your privacy settings allow for the principal name to be read check on your machine in settings-->change pc settings-->Privacy and turn on the needed privacy setting.

This is the complete documentation: http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.userprofile.userinformation.getprincipalnameasync.aspx

6
  • Definitely a domain user - and an admin on the machine that I am developing on.
    – markp3rry
    Feb 7, 2014 at 16:44
  • did you link your user to a microsoft online account when you created it on your windosw 8.1 machine? Feb 10, 2014 at 10:22
  • 1
    also check the settings-->change pc settings-->Privacy. Now turn on all the privacy options and run the app Feb 10, 2014 at 10:27
  • Linking to a Microsoft account will be impossible; this is a line of business application. I will change the PC settings as suggested and give it a go.
    – markp3rry
    Feb 10, 2014 at 10:50
  • 1
    happy to help, I added the complete solution to the answer Feb 10, 2014 at 11:47

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.