gpt4 book ai didi

windows - Windows 通用应用程序中的 ADAL 问题

转载 作者:可可西里 更新时间:2023-11-01 11:17:58 25 4
gpt4 key购买 nike

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

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、authority和resource url。当我从 Windows phone 运行应用程序时,它运行良好。当我在 Windows 10 中运行相同的代码并在 Windows 8.1 中移植相同的逻辑时,应用程序提示输入用户 ID 和密码,输入这些凭据后出现以下错误

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

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

“类型‘Page’在未被引用的程序集中定义。您必须添加一个 引用程序集 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, Pub

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

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

我已经添加了所有功能,例如 internet 和 intert 客户端服务器

最佳答案

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

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

该值默认为 false。

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

关于windows - Windows 通用应用程序中的 ADAL 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29584589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com