ldap.py 812 B

123456789101112131415161718192021222324252627282930
  1. import typer
  2. import config
  3. from misc import apache_ldap
  4. app = typer.Typer()
  5. cfg = config.Config()
  6. @app.command()
  7. def backup():
  8. cred = cfg.cognos11.credentials
  9. apache_ldap.ldap_backup(cred.username, cred.password, f"{cfg.cognos11.config_dir}\\apacheds_backup.ldif")
  10. @app.command()
  11. def restore(backup_file: str):
  12. cred = cfg.cognos11.credentials
  13. apache_ldap.restore_ldap(cred.username, cred.password, backup_file)
  14. @app.command()
  15. def admin_password(old_password: str, new_password: str) -> bool:
  16. return apache_ldap.ldap_change_admin_password(old_password, new_password)
  17. @app.command()
  18. def create_user(new_username: str, new_password: str) -> bool:
  19. cred = cfg.cognos11.credentials
  20. return apache_ldap.ldap_create_user(cred.username, cred.password, new_username, new_password, "")