Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ldap3 import *
- from ldap3.core.exceptions import *
- from colorama import *
- server_name = 'jolas.pt'
- domain_name = 'jolas'
- user_name = 'jolas.pt\Administrador'
- password = ''
- print(Fore.GREEN+'''
- ==================================
- | |
- | |
- | Active Directory Finder |
- | |
- | by: Bruno Teixeira |
- | |
- | |
- ==================================
- ''')
- def connection_to_ad():
- server = Server(server_name, get_info = ALL)
- conn = Connection(server, user = user_name, password = password, authentication = NTLM, auto_bind = True)
- conn.search('dc = {}, dc = pt'.format(domain_name), '(objectclass=person)', attributes = [ALL_ATTRIBUTES,ALL_OPERATIONAL_ATTRIBUTES])
- return conn
- def search(conn):
- name = input('Name: ')
- for people in conn.entries:
- if name == people['sAMAccountName']:
- created = people['whenCreated']
- logoncount = people['logonCount']
- pwdLastSet = people['pwdLastSet']
- lastlogon = people['lastLogon']
- lastlogoff = people['lastLogoff']
- accexpires = people['accountExpires']
- memberoff = people['memberOf']
- print(lastlogon)
- print(f'\nName:{name}\n\nAccountCreated:{created}\n\nPasswordLastSet:{pwdLastSet}\n\nLogonCount:{logoncount}\n\nLastLogon:{lastlogon}\n\nLastLogoff:{lastlogoff}\n\nAccountExpires:{accexpires}\n\nMemberOff:{memberoff}')
- print(Style.RESET_ALL)
- if __name__ == '__main__':
- conn = connection_to_ad()
- search(conn)
Add Comment
Please, Sign In to add comment