简体   繁体   English

从 Java 到 Online Federated Dynamics CRM 2013 的 Web 服务身份验证

[英]Web Service Authentication to Online Federated Dynamics CRM 2013 from Java

I am working on a Java program to integrate via web services with a Microsoft Dynamics CRM 2013 online version.我正在开发一个 Java 程序,通过 Web 服务与 Microsoft Dynamics CRM 2013 在线版本集成。 Authentication is federated with a local IDP, not through Windows Live.身份验证与本地 IDP 联合,而不是通过 Windows Live。 I am having problems finding documentation on how to complete this.我在查找有关如何完成此操作的文档时遇到问题。 All of the non-.NET environment documentation I have seen does not show how to complete the integration in a Federated set-up.我看到的所有非 .NET 环境文档都没有展示如何在联合设置中完成集成。

Is it possible to consume Dynamics CRM web services in this authentication configuration from Java?是否可以通过 Java 在此身份验证配置中使用 Dynamics CRM Web 服务? If so, any documentation/code samples are appreciated.如果是这样,任何文档/代码示例表示赞赏。

Based on my research, it does not seem possible to integrate with Dynamics web services using a federated (local ADFS) ID.根据我的研究,似乎不可能使用联合(本地 ADFS)ID 与 Dynamics Web 服务集成。 The IDP we are using does not respond to WS-Trust RequestSecurityToken and so I was unable to retrieve the SAML.我们使用的 IDP 不响应 WS-Trust RequestSecurityToken,因此我无法检索 SAML。 Even if I was, though, this article suggests that it would not be possible to retrieve the Dynamics SAML:不过,即使我是, 这篇文章也表明不可能检索 Dynamics SAML:

The issue is that the XML SOAP message that access control service accepts has to be signed and the detail on how to do that is internal to the CRM SDK/Identity Model.问题是必须对访问控制服务接受的 XML SOAP 消息进行签名,并且有关如何执行此操作的详细信息是 CRM SDK/身份模型的内部信息。

Since you can't sign the XML message to send to the access control service, integration with CRM 2011 cannot work.由于您无法对要发送到访问控制服务的 XML 消息进行签名,因此无法与 CRM 2011 集成。

The article goes on to state that the workaround is to have a Microsoft Online ID created.文章继续指出解决方法是创建 Microsoft Online ID。 In my case, this is a cloud user within Office 365. Once this user was added to my Dynamics instance, I was able to use the method described in the documentation linked to in the question.就我而言,这是 Office 365 中的云用户。将此用户添加到我的 Dynamics 实例后,我就可以使用问题中链接的文档中描述的方法。

For completeness sake, below is an example of the SOAP request made to https://login.microsoftonline.com/RST2.srf为完整起见,以下是向https://login.microsoftonline.com/RST2.srf发出的 SOAP 请求示例

<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:MessageID>urn:uuid:{GENERATE-GUID-HERE}</a:MessageID>
    <a:ReplyTo>
        <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo4TBVw9fIMZFmc7ZFxBXIcYAAAAAbd1LF/fnfUOzaja8sGev0GKsBdINtR5Jt13WPsZ9dPgACQAA</VsDebuggerCausalityData>
    <a:To s:mustUnderstand="1">https://login.microsoftonline.com/RST2.srf </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">
        <u:Timestamp u:Id="_0">
            <u:Created>{UTC-TIMESTAMP}</u:Created>
            <u:Expires>{UTC-TIMESTAMP}</u:Expires>
        </u:Timestamp>
        <o:UsernameToken u:Id="uuid-14bed392-2320-44ae-859d-fa4ec83df57a-1">
            <o:Username>{CLOUD-USERNAME}</o:Username>
            <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">{CLOUD-PASSWORD}</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">
            <a:EndpointReference>
                <a:Address>urn:crmna:dynamics.com</a:Address>
            </a:EndpointReference>
        </wsp:AppliesTo>
        <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
    </t:RequestSecurityToken>
</s:Body>
</s:Envelope>

Replace the following fields:替换以下字段:

  • MessageID : random GUID MessageID : 随机 GUID
  • Timestamp/Created : current time in ISO-8601 Format : YYYY-MM-DDThh:mm:ss.sssZ时间戳/创建ISO-8601 格式的当前时间:YYYY-MM-DDThh:mm:ss.sssZ
  • Timestamp/Expires : expires time in ISO-8601 Format : YYYY-MM-DDThh:mm:ss.sssZ时间戳/过期ISO-8601 格式的过期时间:YYYY-MM-DDThh:mm:ss.sssZ
  • Username : your cloud username用户名:您的云用户名
  • Password : your cloud password密码:您的云密码

The response will contain a KeyIdentifier and 2 CypherValue elements.响应将包含一个 KeyIdentifier 和 2 个 CypherValue 元素。 Use these to construct the SOAP Header for requests to the CRM.使用这些来构造对 CRM 的请求的 SOAP 标头。 Full code can be found in the link referenced in the question.完整代码可以在问题中引用的链接中找到。

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

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