【问题标题】:ldap3.core.exceptions.LDAPSessionTerminatedByServerError: session terminated by serverldap3.core.exceptions.LDAPSessionTerminatedByServerError:会话被服务器终止
【发布时间】:2018-03-27 16:57:50
【问题描述】:

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

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

关于错误的任何想法?

【问题讨论】:

    标签: python-3.x openldap python-ldap ldap3


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      如果您使用了 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': '绑定响应'})

      【讨论】:

        猜你喜欢
        • 2015-08-13
        • 2012-10-20
        • 2012-09-05
        • 2014-09-07
        • 2018-08-07
        • 1970-01-01
        • 2019-08-16
        • 1970-01-01
        • 2019-07-16
        相关资源
        最近更新 更多