首页 > 解决方案 > 使用 python ldap3 模块搜索具有“uid”的用户时出现此错误

问题描述

使用 python ldap3 模块搜索具有“uid”的用户时出现此错误

错误:

Traceback (most recent call last):
  File "/Users/robinmalhotra/PycharmProjects/pythonProject/main.py", line 6, in <module>
    print(c.extend.standard.who_am_i())
  File "/Users/robinmalhotra/.local/share/virtualenvs/pythonProject-AY4VAyDV/lib/python3.9/site-packages/ldap3/extend/__init__.py", line 65, in who_am_i
    return WhoAmI(self._connection,
  File "/Users/robinmalhotra/.local/share/virtualenvs/pythonProject-AY4VAyDV/lib/python3.9/site-packages/ldap3/extend/operation.py", line 53, in send
    resp = self.connection.extended(self.request_name, self.request_value, self.controls)
  File "/Users/robinmalhotra/.local/share/virtualenvs/pythonProject-AY4VAyDV/lib/python3.9/site-packages/ldap3/core/connection.py", line 1275, in extended
    response = self.post_send_single_response(self.send('extendedReq', request, controls))
  File "/Users/robinmalhotra/.local/share/virtualenvs/pythonProject-AY4VAyDV/lib/python3.9/site-packages/ldap3/strategy/base.py", line 336, in send
    raise LDAPSocketOpenError(self.connection.last_error)
ldap3.core.exceptions.LDAPSocketOpenError: unable to send message, socket is not open

这是我的脚本:

 from ldap3 import Server, Connection, ALL
    
    s = Server(host='oimdevsand', port=389, use_ssl=False, get_info='ALL')
    c = Connection(s, user='uid=idmsa,ou=People,ou=auth,o=ABX', password='XYZ', auto_bind='NONE', version=3, authentication='SIMPLE', \
    client_strategy='SYNC', auto_referrals=True, check_names=True, read_only=False, lazy=False, raise_exceptions=False)
    print(c.extend.standard.who_am_i())
    c.search("ABC","o=abc","(uid=abc)")
    print(c.entries)

标签: pythonldapldap3

解决方案


推荐阅读