Skip to main content

python active directory cli using python-ldap lib to manage ad servers

Project description

padc

cli using python-ldap lib to create connections with Active Directory

Setup for development

python -m venv env && source env/bin/activate && pip install -e .

Create .env file inside root directory to establish a ldap connection

.env

URI='ldap://192.168.0.213'
BIND_DN='administrator@rts.local'
AUTH_PASS='Mypasswd@123'
CA_PATH='' 
BASE_DN='DC=RTS,DC=LOCAL'

padc has logging_settings.ini inside padc/config

[loggers]
keys = root

[handlers]
keys = FileHandler,StreamHandler

[formatters]
keys = simpleFormatter

[logger_root]
level = DEBUG
handlers = FileHandler,StreamHandler

[handler_FileHandler]
class     = FileHandler
formatter = simpleFormatter
args      = ('padc.log', 'a')

[handler_StreamHandler]
class     = StreamHandler
formatter = simpleFormatter
args      = (sys.stdout,)

[formatter_simpleFormatter]
format = %(asctime)s:%(levelname)s: %(message)s

Install padc from pypi

pip install padc

You can modify where log file will be created by editing logging_settings.ini the default file is created at current directory with name 'padc.log'

Running

cli written in Typer to manipulate operations in AD

padc --help

users is the main subcommand, every subcommand has a helper option

pacd users --help

padc has in users subcommand some basic operations if one of the supported operations run with --debug option when errors occurs the traceback and exception will be raised.

exp:

padc users create -f .env "Pingu pythonico" "Pingupassword@123" -c 514 --debug
padc users create-ldif -f .env --ldif example.ldif
padc users add-to-group --file .env "Pingu" "CN=testgroup,CN=Users,DC=RTS,DC=LOCAL" --debug
padc users remove-from-group --file .env "Pingu" "CN=testgroup,CN=Users,DC=RTS,DC=LOCAL"
padc users delete --file .env "Pingu pythonico"
padc users enable -f .env "Pingu" --debug
padc users disable "Pingu" --debug

Testing

Simple Unittest to create/delete/modify user account in AD

python -m unittest -v tests.test_msad

Building

Ensure that you have build package installed first

pip install --upgrade build
python -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

padc-0.3.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

padc-0.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file padc-0.3.tar.gz.

File metadata

  • Download URL: padc-0.3.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for padc-0.3.tar.gz
Algorithm Hash digest
SHA256 7b4705e93439d9f87e4f14d7180be100a24b644694f908107f0b460d3690fa23
MD5 d46c6cc5ac7f5d3e0d9dcf1dd1845917
BLAKE2b-256 a8c59f47db4aaa3c0526bcab9684d212aaa27d0f1e6a4d80d3b4432eb588392f

See more details on using hashes here.

File details

Details for the file padc-0.3-py3-none-any.whl.

File metadata

  • Download URL: padc-0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for padc-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e97c33fdc77da2ee0050921e62e05595717ea2941389344cc60cead9d04cfd9
MD5 b716dbd6827fd7cdbe358ca4d85fbc30
BLAKE2b-256 d4c13a0a51e7d724a9db1f21328f96a8a933ffa95d88e466aa21575a95de3bcc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page