【问题标题】:Issue with ADAL in windows Universal AppsWindows 通用应用程序中的 ADAL 问题
【发布时间】:2015-04-12 00:25:19
【问题描述】:

我正在构建通用应用程序,我正在使用 Azure Active Directory 进行身份验证。我将 Microsoft.IdentityModel.Clients.ActiveDirectory 用于 SSO。适用于 Windows 8.1 和 Window 10 商店应用程序。我一直在参考以下 URL 来连接到我的 Azure Active Directory 并验证用户

http://www.cloudidentity.com/blog/2014/08/28/use-adal-to-connect-your-universal-apps-to-azure-ad-or-adfs/

public  login()
    {
        this.InitializeComponent();
         redirectURI = Windows.Security.Authentication.Web.WebAuthenticationBroker.

                          GetCurrentApplicationCallbackUri();
        authContext = new AuthenticationContext(authority);
    }


    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        // When the app starts, fetch the user's To Do list from the service.
        GetTodoList();
    } 

    private async  void GetTodoList()
    {
        AuthenticationResult result = await authContext.AcquireTokenAsync("https://graph.windows.net", "e11a0451-ac9d-4c89-afd8-d2fa3322ef68", new Uri("http://li"));
        if (result.Status != AuthenticationStatus.Success)
        {

            if (result.Error == "authentication_canceled")
            {
                // The user cancelled the sign-in, no need to display a message.
            }
            else
            {
                MessageDialog dialog = new MessageDialog(string.Format("If the error continues, please contact your administrator.\n\nError: {0}\n\nError Description:\n\n{1} {2}", result.Error, result.ErrorDescription, s1), "Sorry, an error occurred while signing you in.");
                await dialog.ShowAsync();
            }
            return;
        }

我根据我的项目替换了clientID、权限和资源url。当我从 Windows phone 运行 Application 时,它运行良好。当我在 Windows 10 中运行相同的代码并在 Windows 8.1 中移植相同的逻辑时,应用程序会提示输入用户 ID 和密码,输入这些凭据后我收到以下错误

“我们现在无法连接到您需要的服务。请检查您的网络连接或稍后再试一次”

在运行应用程序时,我在 Visual Studio 2015 的输出窗口中看到如下。

“类型‘Page’是在一个没有被引用的程序集中定义的。你必须添加一个 参考程序集'Windows.Foundation.UniversalApiContract, 版本=1.0.0.0,文化=中性,酒吧

类型“IUICommand”在未引用的程序集中定义。您必须添加对程序集的引用 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'licKeyToken=null, 内容类型=Windows 运行时'。 "

我还尝试在 Windows 8.1 上测试相同的 Windows 商店,即使他们也无法验证用户身份。

我已经添加了所有的功能,比如互联网和互联网客户端服务器

【问题讨论】:

    标签: windows windows-store-apps windows-10 win-universal-app adal


    【解决方案1】:

    将以下内容添加到 config.xml:

      <preference name="adal-use-corporate-network" value="true" /> 
    

    默认值为 false。

    更多信息在这里: https://github.com/AzureAD/azure-activedirectory-library-for-cordova

    【讨论】:

      【解决方案2】:

      通过为身份验证上下文添加 useCorpnetnetwork = true 以及在清单(如 internet、internetclientsever、shared certificate )中的更改来解决此问题。我错过了包中的共享认证

      【讨论】:

      • 我也遇到了在 corpnet 中登录的问题。你能分享一个示例清单文件吗?或指出他清单所需的确切键值对?非常感谢!
      猜你喜欢
      • 2021-08-20
      • 1970-01-01
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      • 1970-01-01
      相关资源
      最近更新 更多