2

我正在尝试运行试图建立连接的代码:

server = Server(host='localhost', port=33389, use_ssl=False, get_info=ALL)
conn = Connection(server, user='uid=admin,ou=people,dc=example,dc=org', password=user-pass, raise_exceptions=False, authentication=SIMPLE)
print(server.info)
print(conn)

以下是错误详细信息:

None
ldap://localhost:33389 - cleartext - user: uid=admin,ou=people,dc=hadoop,dc=apache,dc=org - not lazy - unbound - closed - <no socket> - tls not started - not listening - SyncStrategy - internal decoder
**************************
Traceback (most recent call last):
  File "knox_connect.py", line 116, in <module>
    main()
  File "knox_connect.py", line 112, in main
    print(get_knox_users())
  File "knox_connect.py", line 63, in get_knox_users
    conn.open()
  File "/usr/local/lib/python3.5/dist-packages/ldap3/strategy/sync.py", line 59, in open
    self.connection.refresh_server_info()
  File "/usr/local/lib/python3.5/dist-packages/ldap3/core/connection.py", line 1325, in refresh_server_info
    self.server.get_info_from_server(self)
  File "/usr/local/lib/python3.5/dist-packages/ldap3/core/server.py", line 448, in get_info_from_server
    self._get_dsa_info(connection)
  File "/usr/local/lib/python3.5/dist-packages/ldap3/core/server.py", line 364, in _get_dsa_info
    get_operational_attributes=True)
  File "/usr/local/lib/python3.5/dist-packages/ldap3/core/connection.py", line 775, in search
    response = self.post_send_search(self.send('searchRequest', request, controls))
  File "/usr/local/lib/python3.5/dist-packages/ldap3/strategy/sync.py", line 142, in post_send_search
    responses, result = self.get_response(message_id)
  File "/usr/local/lib/python3.5/dist-packages/ldap3/strategy/base.py", line 345, in get_response
    raise LDAPSessionTerminatedByServerError(self.connection.last_error)
ldap3.core.exceptions.LDAPSessionTerminatedByServerError: session terminated by server

关于错误的任何想法?

4

2 回答 2

0

在阅读信息之前,您必须使用 conn.bind() 方法打开连接。

于 2018-05-19T07:26:08.367 回答
0

如果您使用 print(conn.result) ,它将显示更多详细信息,其中包含“描述”和“消息”,您可以在其中找到终止它的正确原因。

例如:- {'dn': u'', 'saslCreds': None, 'referrals': None, 'description': 'inappropriateAuthentication', 'result': 48, 'message': u'Inappropriate authentication', 'type ':'绑定响应'}

{'dn': u'', 'saslCreds': None, 'referrals': None, 'description': 'success', 'result': 0, 'message': u'', 'type': 'bindResponse' })

于 2022-03-01T05:59:14.563 回答