Begin phicli

This commit is contained in:
uid 2020-10-10 18:45:16 +02:00
parent 86e8ed669b
commit 75e2ee1b04
3 changed files with 32 additions and 7 deletions

View File

@ -14,12 +14,10 @@ ldap:
validate: True # Can either be True or False. Default: False
ca_certs: openldap/cert.pem
username: uid=phi,ou=Services,dc=unit,dc=macaomilano,dc=org
password: phi
base_dn: dc=unit,dc=macaomilano,dc=org
attribute_id: uid
attribute_mail: mail
# username: uid=phi,ou=Services,dc=unit,dc=macaomilano,dc=org
# password: phi
username: cn=root,dc=unit,dc=macaomilano,dc=org
password: root
logging:

View File

@ -14,7 +14,7 @@ setup(
package_dir={'': 'src'},
packages=['phi', 'phi.api', 'phi.ldap'],
scripts=['src/phid'],
scripts=['src/phid', 'src/phicli'],
setup_requires=['pytest-runner'],
install_requires=['pyYAML', 'ldap3'],

27
src/phicli Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env python3
from pprint import pformat as pp
import phi.ldap.client
from phi.config import get_config
from phi.logging import setup_logging, get_logger
log = get_logger(__name__)
if __name__ == '__main__':
config_file, config = get_config()
setup_logging(config.get('logging', {}))
# log.info("Found configuration at '{}':\n{}"
# .format(config_file, pp(config)))
log.info("Found configuration at '{}':\n".format(config_file))
log.info('Opening LDAP client')
client = phi.ldap.client.Client(**config['ldap'])
client.open()
#
log.info('Closing LDAP client')
client.close()