0

我在 python 中使用 Ldap3 模块来查询 AD,但是如果广告帐户在前 1000 次搜索中我会得到结果,我在 AD 中有超过 25000 + 用户 ID,我如何将我的代码更改为简单的页面搜索,请帮助我。

''''

import sys
from ldap3 import Server, Connection, ALL, NTLM, ALL_ATTRIBUTES, ALL_OPERATIONAL_ATTRIBUTES, AUTO_BIND_NO_TLS, SUBTREE
from ldap3.core.exceptions import LDAPCursorError


server = Server('bluepedia.com',get_info=ALL)
conn = Connection(server, user='bluepedia\\administrator', password='Vihaan@2016', authentication=NTLM)
conn.bind()
fusers = ['vihaan','phani','rammohan','raja','bindu','MA977956', 'MA625841','gopal','govind','MA177397','MA259156']
status = ''
usermail= ''

format_string = '{:25} {:21} {}'
print(format_string.format('User ID', 'Account Status', 'E-mail Address'))

conn.search('dc=bluepedia,dc=com', '(objectclass=person)',attributes=['sAMAccountName', 'mail'])

for x in fusers:
    for e in conn.entries:
        usermail = e.mail
        if x in e.sAMAccountName:
            # status = 'active' +"\t\t\t\t"+ str(usermail)
            status = 'active'
            break
        else:
            status = "Not Active"
        usermail = ''
    print(format_string.format(str(x),str(status),str(usermail)))

''''

我需要的结果是我想使用 Ldap3 模块从列表中搜索用户 ID,并且列表中有 10000 个用户。

4

0 回答 0