How can I connect to a Microsoft Dynamics CRM server using Python?

一个人想着一个人 提交于 2020-01-10 11:46:30

问题


The Microsoft Dynamics CRM service uses NTLM authentication, which makes connecting to it from a python process using suds somewhat complicated. I'm looking for a code sample that will:

  1. Send and receive the response from a RetrieveAttributeRequest
  2. Send and receive the response from an Execute request.

This must use Python 2.6 or Python 2.7, not Python 3. I already have a working implementation that uses curl to do this, but it's flaky at the best of times, and as part of some other work I have in this tool I'd like to clean it up and make it run using python/suds.


回答1:


I know this is a bit late but hopefully it will help someone.

NTLM authentication was added to suds in version 0.3.8.

from suds.transport.https import WindowsHttpAuthenticated
from suds.client import Client

url = 'http://crmurl/XRMServices/2011/Discovery.svc?wsdl'
ntlm = WindowsHttpAuthenticated(username='DOMAIN\username', password='password')
client = Client(url, transport=ntlm)



回答2:


I don't know if this will be of help to you, but I used PycURL to get through an NTLM proxy.

Here's a code snippet:

    c = Curl()

    c.setopt(URL, 'http://www.somesite.com')
    c.setopt(FOLLOWLOCATION, 1)           # follow redirects
    c.setopt(MAXREDIRS, 5)              # max redirects
    c.setopt(PROXY, 'proxy.somesite.com')
    c.setopt(PROXYUSERPWD, 'DOMAIN/USER:PASSWORD')
    c.setopt(PROXYAUTH, HTTPAUTH_NTLM)    # use NTLM

    c.perform()

Here's the documentation on the Curl object.



来源:https://stackoverflow.com/questions/3294587/how-can-i-connect-to-a-microsoft-dynamics-crm-server-using-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!