Imported sources.
This commit is contained in:
26
scripts/login.py
Normal file
26
scripts/login.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from getpass import getpass
|
||||
from ldap3 import Server, Connection, ALL
|
||||
from ldap3 import ObjectDef, AttrDef, Reader, Writer, Entry, Attribute, OperationalAttribute
|
||||
import keyring
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="LDAP Test Script")
|
||||
|
||||
# Generic LDAP connection parameters
|
||||
parser.add_argument("--host", "-H", default="gra-01.koszewscy.waw.pl", help="LDAP server host")
|
||||
parser.add_argument("--port", "-p", type=int, default=389, help="LDAP server port")
|
||||
parser.add_argument("--base-dn", "-b", default="dc=koszewscy,dc=waw,dc=pl", help="Base DN for LDAP operations")
|
||||
parser.add_argument("--user", "-u", default="cn=admin,dc=koszewscy,dc=waw,dc=pl", help="Bind DN for LDAP connection")
|
||||
|
||||
# Specific parameters
|
||||
parser.add_argument("--object-class", "-c", nargs='*', default=["inetOrgPerson"], help="Object class(es) to work with")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
server = Server(args.host, port=args.port, get_info=ALL)
|
||||
password = keyring.get_password("Home Lab Password", "admin") or getpass("Password: ")
|
||||
|
||||
conn = Connection(server, user=args.user, password=password, auto_bind=True)
|
||||
person = ObjectDef(args.object_class, conn)
|
||||
print(person)
|
||||
conn.unbind()
|
||||
Reference in New Issue
Block a user