0

I am using Ldap3 module in python to query AD, however i get result if the ad account is in first 1000 searches, i have more than 25000 + user ids in AD, how i can change my code here into simple page search, Please help me.

''''

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)))

''''

My required result is i want to search user id from a list using Ldap3 module, and i have 10000 users in list.

0 Answers0