Python 这是什么意思;无法发送消息,套接字未打开";?

Python 这是什么意思;无法发送消息,套接字未打开";?,python,python-3.x,ldap,Python,Python 3.x,Ldap,我正在尝试连接到ldap服务器,但它似乎以某种方式或形式出现故障: import csv from ldap3 import Server, Connection, ALL, NTLM, SUBTREE import pandas as pd server = Server('cybertest02.ad.arb.ca.gov', get_info=ALL) c = Connection(server, user='myusername', password='mypassword') c

我正在尝试连接到ldap服务器,但它似乎以某种方式或形式出现故障:

import csv
from ldap3 import Server, Connection, ALL, NTLM, SUBTREE
import pandas as pd


server = Server('cybertest02.ad.arb.ca.gov', get_info=ALL)
c = Connection(server, user='myusername', password='mypassword')

c.search(search_base = 'o=test',
         search_filter = '(objectClass=inetOrgPerson)',
         search_scope = SUBTREE,
         attributes = ['cn', 'givenName'])

total_entries += len(c.response)
for entry in c.response:
    print(entry['dn'], entry['attributes'])
第12行错误:属性为,无法发送消息,套接字未打开

请尝试在
c.search()
语句之前和
Connection()之后插入
c.bind()

根据,您必须在服务器中建立新的授权状态

  • 如RFC4511所述,绑定操作是“身份验证”操作

  • 打开到LDAP服务器的连接时,您处于匿名连接状态。这到底意味着什么是由服务器实现定义的,而不是由协议定义的

  • bind()
    方法将打开尚未打开的连接

  • 绑定操作与套接字无关,而是执行用户的身份验证


您还应该使用来关闭连接。

可以显示整个堆栈跟踪吗?如果bind()返回False,则表示凭据错误。您可以检查c.result以查看从服务器收到的错误的详细信息。