简体   繁体   中英

How to get the Domain of Current User programmatically in Store Apps

We developed an store app it works fine when we deployed in domain2 it not working.As it throwing an error we fixed that error in the domain2 and installed in the domain1 it doesn't work but it working fine in domain2.

I tried using

string dnsName = await Windows.System.UserProfile.UserInformation.GetDomainNameAsync();

but it returning empty string

for eg, I'm having two domains like Dev and Test,my need is to get the name as Dev and Test.

any solution or code is provided is much appreciated.

Use of this requires the Enterprise Authentication capability, which in turn requires a business account (not an individual developer account) on the Windows Store. All that's possible to do of course.

I'd thought the result would be blank if Enterprise Authentication were not checked. The documentation says that GetDomainNameAsync does not throw an exception, but I'm definitely seeing a UnauthorizedAccessException in that case.

So presuming that is not the issue, note you will get an empty string on that call if the user turned off the sharing of that information via PC Setttings:

在此处输入图片说明

For getting Domain name for user you have to use

string dnsName = Windows.System.UserProfile.UserInformation.GetDomainNameAsync();

Click Here for MSDN ,Here is the User domain name sample on MSDN .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM