简体   繁体   English

从ADAL .NET到ADFS

[英]ADAL .NET to ADFS

I am trying to do exactly what this library is designed to do: allow my .NET code (currently a test console app) to retrieve a token from ADFS for the current user, and use the token to authenticate with and call a REST Web API endpoint. 我正在尝试完全执行该库的设计工作:允许我的.NET代码(当前为测试控制台应用程序)从ADFS检索当前用户的令牌,并使用该令牌进行身份验证并调用REST Web API端点。 This article calls it the basic flow supported by ADAL. 本文将其称为ADAL支持的基本流程。 My organisation run Windows Server 2012 SP2 ADFS. 我的组织运行Windows Server 2012 SP2 ADFS。 The console app and ADFS are on-premise. 控制台应用程序和ADFS在本地。

Can anyone point me to a full example of how to set this up and use it? 谁能指出我如何设置和使用它的完整示例? The code snippets are fine, but there's a lot around it that's not explained - like what is the Authentication Context endpoint? 代码段很好,但是周围有很多未解释的内容,例如Authentication Context端点是什么? What do I ask my sysadmins for? 我要问我的系统管理员什么? They have given me an STS endpoint, but that does not seem to work. 他们给了我一个STS端点,但这似乎行不通。 I think I need more than just a server URL, probably need to be passed a query string or other extension, but I can't find any explanation around that. 我想我不仅需要服务器URL,可能还需要传递查询字符串或其他扩展名,但是我找不到关于它的任何解释。 Virtually all the samples and examples I have found deal with registering the Client app with Azure, and I am not using Azure. 我发现的几乎所有示例和示例都涉及在Azure中注册客户端应用程序,而我没有使用Azure。

My code currently looks like this: 我的代码当前如下所示:

AuthenticationContext authenticationContext = new AuthenticationContext("https://sts.myorg.co.za");
var token = authenticationContext.AcquireToken("http://myservices/service1", "a8cb2a71-da38-4cf4-9023-7799d00e09f6", new Uri("http://TodoListClient"));

but the call to AquireToken fails with an exception saying This method overload is not supported by 'https://sts.myorg.co.za' . 但是对AquireToken的调用失败,并出现一个异常,说明This method overload is not supported by 'https://sts.myorg.co.za'

Any help or pointers appreciated! 任何帮助或指针表示赞赏!

Thanks, Peter 谢谢彼得

您应该将validateAuthority = false传递给ADAL的构造函数。

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

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