简体   繁体   English

如何在Store Apps中以编程方式获取当前用户的域

[英]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. 我们开发了一个商店应用程序,当它在domain2中部署时无法正常工作,因为它抛出了错误,所以我们修复了该错误并在domain2中修复了该错误,然后将其安装在domain1中则无法正常工作,但在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. 例如,我有两个域,例如Dev和Test,我的需要是将名称命名为Dev和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. 使用此功能需要企业身份验证功能,而企业身份验证功能又需要Windows应用商店中的企业帐户(而不是单个开发人员帐户)。 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. 该文档说GetDomainNameAsync不会引发异常,但是在这种情况下,我肯定会看到UnauthorizedAccessException。

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: 因此,假设这不是问题,请注意,如果用户关闭了通过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 . 点击这里MSDN ,这是对用户域名样品MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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