Python 3 LDAP 3-使用来自不同域的用户连接到AD

eblbsuwk  于 2023-04-22  发布在  Python
关注(0)|答案(2)|浏览(239)

在Python 3中,使用LDAP3模块,是否可以使用来自不同AD的用户连接到AD?
我试图设置连接字符串使用Domain2中的帐户,以便连接到Domain1,但它不起作用,我得到一个错误,说明凭据无效,即使当我尝试使用同一帐户连接到Domain2时,它们也有效。

Traceback (most recent call last):
  File "mailer.py", line 47, in <module>
    conn = Connection(server, domain["connection_string"], domain["password"], auto_bind=True)
  File "/usr/lib/python3/dist-packages/ldap3/core/connection.py", line 321, in __init__
    self.do_auto_bind()
  File "/usr/lib/python3/dist-packages/ldap3/core/connection.py", line 349, in do_auto_bind
    raise LDAPBindError(self.last_error)
ldap3.core.exceptions.LDAPBindError: automatic bind not successful - invalidCredentials

这是可能的,还是LDAP3连接只适用于来自同一个域的用户?
编辑:
这就是我试图使用连接时,我得到上面的错误消息。

server = Server(domain1.example.com)
conn = Connection(server, "CN=BindAccount,OU=Users,DC=domain2,DC=example,DC=com", '#Password1', auto_bind=True)
fnx2tebb

fnx2tebb1#

使用ldap3,你可以绑定到任何ldap服务器,没有与Active Directory域相关的限制。实际上,LDAP根本不知道AD。可能你提供了错误的凭据。

qxsslcnc

qxsslcnc2#

即使您连接到domain1,您仍然可以搜索domain2。例如,如果域是

DC = 'dc=domain,dc=example,dc=com'

你仍然可以

conn.search('dc=example,dc=com', query)

从example.com的所有子域获取结果。

相关问题