diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..37a4394 --- /dev/null +++ b/.gitignore @@ -0,0 +1,127 @@ +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# config file +*config.yml +*config.py +*config.ini +*config.json + +# config/secret/certs files +*.key +*.crt +*secrets.ini +*client.conf \ No newline at end of file diff --git a/config.ini.sample b/config.ini.sample new file mode 100644 index 0000000..e69de29 diff --git a/seafile-ldap.py b/seafile-ldap.py new file mode 100644 index 0000000..5ac1f2d --- /dev/null +++ b/seafile-ldap.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +from ldap3 import Connection, Server, ANONYMOUS, SIMPLE, SYNC, ASYNC +from getpass import getpass + +server = Server('gauntdc01.home.johnhgaunt.com', port=636, use_ssl=True) + +username = input("Username: ") +password = getpass("Password: ") + + #Create a connection object, and bind with the given DN and password. +try: + conn = Connection(server, username, password, auto_bind=True) + print('LDAP Bind Successful.') + # Perform a search for a pre-defined criteria. + # Mention the search filter / filter type and attributes. + conn.search('CN=Users,dc=home,dc=johnhgaunt,dc=com', '(&(mail=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(memberOf=CN=Seafile,CN=Users,DC=home,DC=johnhgaunt,DC=com))') + # Print the resulting entries. + for entry in conn.entries: + print(entry) +except core.exceptions.LDAPBindError as e: + # If the LDAP bind failed for reasons such as authentication failure. + print('LDAP Bind Failed: ', e) \ No newline at end of file