【问题标题】:Claim auth from ADFS从 ADFS 声明身份验证
【发布时间】:2012-07-03 00:02:48
【问题描述】:

我尝试通过 WPF 应用程序连接到 SharePoint Online 实例。我发现 this article 描述了一个可能的解决方案,但问题是特定实例前面有一个 Active Directory 联合身份验证服务 (ADFS),我不知道如何获取身份验证令牌。 (我无法为我的应用程序创建证书以针对 adfs 进行身份验证。)

任何已经这样做并且可以用一些代码sn-ps支持我的人吗?

【问题讨论】:

  • 我还没有这样做,但我可能会提供帮助。您可以在某处发布从使用 ADFS 到 Office 365 的常规基于 Web 的登录中提取的 Fiddler 跟踪吗?
  • @woloski 由于跟踪中的公司信息,我无法发布此内容。如果你给我你的地址,我可以邮寄给你。 (您可以在我的个人资料中找到我的(
  • 我已经给你发了一封电子邮件。收到了吗?
  • 是的,我有,明天我会把踪迹发给你;-)

标签: c# sharepoint authentication active-directory adfs


【解决方案1】:

我和 Fiddler 一起玩过。基本上流程是这样的:

  • 从 ADFS 获取 SAML 令牌
  • 发布到https://login.microsoftonline.com/login.srf(正文应该是wa=wsignin1.0, wresult=<requestsecuritytokenresponse>…token…</rstr> and wctx=MEST=0&LoginOptions=2&wa=wsignin1%2E0&rpsnv=2&ct=1343219880&rver=6%2E1%2E6206%2E0&wp=MBI&wreply=https%3A%2F%2Fspirit365%2Esharepoint%2Ecom%2F%5Fforms%2Fdefault%2Easpx&id=500046&cbcxt=mai&wlidp=1&guest=1&vv=910&mkt=EN-US&lc=1033&bk=1343219930
  • 从表单中捕获名为“t”的隐藏输入
  • 将该“t”发布到 /_layouts/Authenticate.aspx。那应该给你 FedAuth 和 rtFa cookie。

从那时起,这与此处的代码相同:http://www.wictorwilen.se/Post/How-to-do-active-authentication-to-Office-365-and-SharePoint-Online.aspx

【讨论】:

  • 我听说 rtFa cookie 的目的是让用户退出。我该怎么做?将 rtFa 附加到 HTTP 请求并将其发送到任何 SharePoint Web 服务?
【解决方案2】:

我找到了解决方案并发表了一篇关于它的帖子。我也把它放在github 上。您可以在 my blog 找到我的博文以及 github 链接。

我希望这能像它帮助我一样帮助你:-)

【讨论】:

  • 你能再发一次吗?
  • @retrography 博客因维护而停机,但我在帖子中添加了 GitHub 链接。如果您仍然需要博客文章,请给我写一封电子邮件,我将其发送给您;-)
  • @jwillmer 从我可以看到您的代码适用于 Windows 8,但是 Window 10 怎么样?我确实尝试过测试它,但它不适用于 Win10。
【解决方案3】:

我花了很多时间终于弄明白了。为了获取二进制令牌,您需要将以下格式的消息发布到 Microsoft 在线安全令牌服务 (STS) 站点 URL:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <a:To s:mustUnderstand="1">[toUrl]</a:To>
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      [assertion]
    </o:Security>
  </s:Header>
  <s:Body>
    <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
      <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <a:EndpointReference>
          <a:Address>[url]</a:Address>
        </a:EndpointReference>
      </wsp:AppliesTo>
      <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
      <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
      <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
    </t:RequestSecurityToken>
  </s:Body>
</s:Envelope>

需要此消息才能将标记替换为以下值:

[toUrl]:Microsoft 在线安全令牌服务 (STS) 站点 URL。
[url]:您的 SP 站点 URL
[assertion]:您是否从联合服务中获得了断言 XLM 令牌。

从响应 XML 中获取 t=... 二进制令牌后,您可以将其发布到您的 SP default.aspx 以获取 cookie。

【讨论】:

  • 我已经尝试过这种方法,并获得了 Fedauth cookie,但是当我重定向到 SharePoint 在线网站时,它再次要求用户凭据。如果我在本地将主机条目设为“testO365.sharpoint.com”,那么它的工作正常,任何建议。
  • 嗨,我知道这是一个旧帖子。但也许有人可以帮助我坚强。我设法从我们的 adfs-server 获取断言 xml。但是,如果我将它( 和里面的任何东西)复制到 xml 中,我总是会收到错误声明“websso 无效断言”(顺便说一句。我发布到(login.microsoftonline.com/extsts.srf
  • 求助:你把代码放到哪里了?我正在使用 C#,但我不明白它是从哪里放置和调用的。
【解决方案4】:

对于任何有麻烦的人(真的很难),这里有一些澄清

这四个步骤是 1)从您的 SAML IDP 中获取断言 2) 用断言换取 STS 代币 3) 用 STS 代币换取 cookie 4)使用cookies做你的休息电话

对于第 1 步,我已 ping 联邦。在邮递员中使用它来发布到您的令牌 ID 处理器以获取断言: POST https://pingfederate/idp/sts.wst?TokenProcessorId=username

<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope' xmlns:a='http://www.w3.org/2005/08/addressing' xmlns:u='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
    <s:Header>
        <a:Action s:mustUnderstand='1'>http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
        <a:ReplyTo>
            <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
        </a:ReplyTo>
        <o:Security s:mustUnderstand='1' xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
            <o:UsernameToken>
                <o:Username>yourusername</o:Username>
                <o:Password>yourpass</o:Password>
            </o:UsernameToken>
        </o:Security>
    </s:Header>
    <s:Body>
        <t:RequestSecurityToken xmlns:t='http://schemas.xmlsoap.org/ws/2005/02/trust'>
            <wsp:AppliesTo xmlns:wsp='http://schemas.xmlsoap.org/ws/2004/09/policy'>
                <wsa:EndpointReference xmlns:wsa='http://www.w3.org/2005/08/addressing'>
                    <wsa:Address>urn:federation:MicrosoftOnline</wsa:Address>
                </wsa:EndpointReference>
            </wsp:AppliesTo>
            <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
        </t:RequestSecurityToken>
    </s:Body>
</s:Envelope>

它将生成一个包含断言的信封。确保以原始格式(不是漂亮的 xml)复制它。从

的所有内容

对于第 2 步,当您 POST 到 https://login.microsoftonline.com/extSTS.srf 时,请确保以原始格式(不是漂亮的 XML)粘贴断言。

用途:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <saml:Assertion AssertionID="hp4CtHjK_lL" Issue Instant...................../ds:Signature></saml:Assertion>
    </o:Security>
  </s:Header>
  <s:Body>
    <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
      <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <a:EndpointReference>
          <a:Address>https://myshare.sharepoint.com/sites/mysite</a:Address>
        </a:EndpointReference>
      </wsp:AppliesTo>
      <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
      <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
      <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
    </t:RequestSecurityToken>
  </s:Body>
</s:Envelope>

对于第 3 步,POST 到 https://myshare.sharepoint.com/_forms/default.aspx?wa=wsignin1.0 并确保您的用户代理是常规用户代理,例如 Mozilla/5.0(兼容;MSIE 9.0;Windows NT 6.1;Win64;x64;Trident/5.0)。 在帖子的正文中,它将是第 2 步生成的

第 4 步,获取 cookie 后,即可获取共享点列表

https://myshare.sharepoint.com/sites/mysite/_api/Web/Lists/GetByTitle('Updating%20List%E2%80%8B')/items

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-11
    • 2012-11-08
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多