Metadata-Version: 2.1
Name: padc
Version: 0.2
Summary: python active directory cli using python-ldap lib to manage ad servers
Home-page: https://github.com/Fabiokleis/p_ad
Author: Fabio Kleis
Author-email: fabiohkrc@gmail.com
License: MIT License
        
        Copyright (c) 2023 Fabio Kleis
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Description-Content-Type: text/markdown
License-File: LICENSE

# p_ad

lab using [python-ldap](https://github.com/python-ldap/python-ldap) lib to create connection with Active Directory

## Setup
```console
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'
```

## Running
p_ad has a cli written in [Typer](https://github.com/tiangolo/typer) to manipulate operations in AD
```console
./env/bin/padc --help
```
`users` is the main subcommand, every subcommand has a helper option
```console
./env/bin/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:
```console
./env/bin/padc users create -f .env "Pingu pythonico" "Pingupassword@123" -c 514 --debug
```
```console
./env/bin/padc users create-ldif -f .env --ldif example.ldif
```
```console
./env/bin/padc users add-to-group --file .env "Pingu" "CN=testgroup,CN=Users,DC=RTS,DC=LOCAL" --debug
```
```console
./env/bin/padc users remove-from-group --file .env "Pingu" "CN=testgroup,CN=Users,DC=RTS,DC=LOCAL"
```
```console
./env/bin/padc users delete --file .env "Pingu pythonico"
```
```console
./env/bin/padc users enable -f .env "Pingu" --debug
```
```console
./env/bin/padc users disable "Pingu" --debug
```

## Testing
Simple Unittest to create/delete/modify user account in AD
```console
python -m unittest -v tests.test_msad
```

## Building
Ensure that you have build package installed first
```console
pip install --upgrade build
```

```console
python -m build
```
