0

我正在尝试使用 Python 中的 ldap 库绑定到 LDAP 服务器。但是,每次我尝试在 Python 中使用 sasl_interactive_bind_s() 时,都会收到以下错误:

AttributeError: sasl_interactive_bind_s

我不知道为什么会这样,而且错误消息也不是很有帮助。这是我正在使用的代码。(dc.hostname 只是服务器名称)

conn = ldap.initialize("ldap://" + dc.hostname + ":3268")
conn.set_option(ldap.OPT_NETWORK_TIMEOUT, 5)
conn.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3)
conn.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)
conn.set_option(ldap.OPT_RESTART, ldap.OPT_ON)
sasl_cb_value_dict = {}
sasl_cb_value_dict[ldap.sasl.CB_AUTHNAME] = bind_dn
sasl_cb_value_dict[ldap.sasl.CB_PASS] = admin_pw
auth_tokens = ldap.sasl.sasl(sasl_cb_value_dict,"DIGEST-MD5")
conn.sasl_interactive_bind_s("", auth_tokens)

为了尝试规避这一点,我还尝试使用 C 函数进行绑定ldap_sasl_bind_s(),这有助于成功绑定。但是,现在我不知道如何将此连接对象传递回 Python,以便查询 LDAP 服务器。(注意:我ldap_search_ext_s()在 C 中使用了该函数,但它从未真正返回任何内容,因为查询时间太长)

任何帮助/建议将不胜感激。提前致谢!

4

0 回答 0