2017-01-09 72 views
0

我试图找到一种方法来从网络URI(而非网站)下载需要LDAP身份验证的CSV。我对这个做了一个服务帐户,但我没能找到工作的解决方案:使用LDAP身份验证下载文件

conn = ldap.open("10.41.10.10:389") #I've tried different URIs 
conn.simple_bind_s('[email protected]', 'password')  
call = open(r'\\fserv03\reports\gps_List.csv') 

有没有更好的方式来做到这一点?

更新:在下载Python-LDAP工作后,我的Python-LDAP为我的64位安装工作,我下载了python_ldap-2.4.28-cp27-cp27m-win_amd64并在其上运行pip安装。

+0

什么错误(S)你好吗?你有没有试过类似'ldap:// 10.41.10.10'或'ldaps:// 10.41.10.10'? – alecxe

+0

LDAPError:(2,'没有这样的文件或目录')。我是否需要以某种方式将LDAP网络中的网络URI传入? – LampShade

回答

0

我能得到这个具有以下(使用Python-LDAP库)工作:

try: 
    l = ldap.initialize('ldap://LDAP SERVER HERE') 
    l.protocol_version = ldap.VERSION2 
    username = "cn=USER, o=example.com" 
    password = 'PASSWORD HERE' 
    l.simple_bind(username, password) 
except ldap.LDAPError, e: 
    print e