簡體   English   中英

無法讓 Python ldap3 顯示架構

[英]Can't get Python ldap3 to show schema

我有一個項目來刪除大型 LDAP 數據庫中的重復項,但到目前為止......

我只是想獲取架構,但什么都看不到:

>> import ldap3
>>> s = ldap3.Server('ldaps://omitted')
>>> s.schema
>>> s2 = ldap3.Server('ldaps://omitted',get_info=ldap3.ALL)
>>> s2.schema
>>> s2.info
>>> s.info

(省略了 URL,因為我還沒有得到雇主的許可。)

對此有任何想法嗎? 服務器設置在安全性之后,不需要任何身份驗證即可連接。

好吧,你必須先綁定你的連接。 嘗試這個:

from ldap3 import Connection, Server

# take 636 for secured connection, use_ssl=True may be necessary
server = Server('myhost.company.com', port=389) 
cnx = Connection(server, user='cn=user', password='whatever')
# either use auto_bind=True or set bind explicitly
cnx.bind()
# now you should be able to see the schema
# Caution: depending on the schema, it may take quite long to show it
print(server.schema)

這只是部分答案,但我已經取得了一些進展。 重要信息是服務器確實需要身份驗證,即使我第一次看到的 PHP 代碼似乎沒有使用它。

我現在有這個代碼:


from pprint import pprint
from ldap3 import Server, Connection, SAFE_SYNC, ALL

search_base = '*omitted*'
search_filter = '(uid=mmcwiggins)'
attrs = ['*']

server = Server('ldaps://*omitted*', get_info=ALL)
mypass = 'not.really.the.pass'.encode('iso-8859-1')
connect = Connection(server, user='mmcwiggins', password=mypass)
connect.bind()
print(connect)
print(server.schema)

這會產生以下響應:

ldaps://lbdc.secret.company.com:636 - ssl - user: mmcwiggins - not lazy - unbound - open - <local: 10.184.200.19:49737 - remote: 10.184.67.152:636> - tls not started - listening - SyncStrategy - internal decoder
None

看到這個后有什么想法嗎?

我終於使用 ldapsearch 而不是 Python 讓它工作了。

我得到了當地大師的幫助; 它需要主目錄中的.ldaprc文件。 此文件中的關鍵參數是TLS_REQCERT ALLOW

完整的命令行是這樣的(企業標識被屏蔽):

ldapsearch -x -D "SEA\mmcwiggins" -b "DC=SEA,DC=CORP,DC=*****,DC=COM" -E pr=1000/noprompt -H ldaps://lbdc.sea.corp.******.com -W sAMAccountName='*' >bigresult

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM