我尝试使用运行良好的 python 查询 Active Directory 服务器。但现在我不想通过网络发送未加密的凭据,所以我想使用 LDAP。是否有捷径可寻?到目前为止,我发现我必须添加这个选项:
l.set_option(ldap.OPT_X_TLS_CACERTFILE,'/path/to/my/Ca.pem')
但我实际上不想获得 CA 证书或正确的证书并验证它。当然,从安全角度来看,我应该验证我的通信伙伴是正确的,但我不在乎我的内部网络,只是希望这更容易处理。如果我只是将 LDAP URL 从 ldap 更改为 ldaps 我会收到此错误:
Traceback (most recent call last):
File "./ldap-to-sql.py", line 21, in <module>
bind = l.simple_bind_s(USERNAME, PASS)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 214, in simple_bind_s
msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 208, in simple_bind
return self._ldap_call(self._l.simple_bind,who,cred,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 106, in _ldap_call
result = func(*args,**kwargs)
ldap.SERVER_DOWN: {'info': 'SSLHandshake() failed: misc. bad certificate (-9825)', 'desc': "Can't contact LDAP server"}