开发者

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

The Microsoft Dynamics CRM service uses NTLM authentication, which mak开发者_开发技巧es 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.


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜