2

I am trying to run the code which is trying to build a connection:

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)

Below is the error detail:

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

Any idea about the error?

yguw
  • 856
  • 6
  • 12
  • 32
user5431918
  • 107
  • 1
  • 6

2 Answers2

0

You must open the connection with the conn.bind() method before reading info.

cannatag
  • 1,528
  • 11
  • 17
0

if you used print(conn.result) it will display more details with "description" and "message" where you can find the proper reason why it is terminated.

example:- {'dn': u'', 'saslCreds': None, 'referrals': None, 'description': 'inappropriateAuthentication', 'result': 48, 'message': u'Inappropriate authentication', 'type': 'bindResponse'}

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