Sync Active Directory groups to CiviCRM
Find a file
2025-04-09 10:58:33 +02:00
.idea 🔖 Bump version: 0.1.0 → 1.0.0 2025-03-20 15:32:42 +01:00
src 🔖 Bump version: 1.3.0 → 1.4.0 2025-04-01 18:58:13 +02:00
.gitignore replace tomlib with tomlkit 2025-03-21 13:24:28 +01:00
.python-version 🔖 Bump version: 0.1.0 → 1.0.0 2025-03-20 15:32:42 +01:00
LICENSE.md 📄 add MIT license 2025-04-09 10:58:33 +02:00
pyproject.toml 🔖 Bump version: 1.3.0 → 1.4.0 2025-04-01 18:58:13 +02:00
README.md MOD: Added cron job creation documentation 2025-04-01 10:19:58 +02:00
uv.lock 🔖 Bump version: 1.2.0 → 1.3.0 2025-03-27 18:41:44 +01:00

adGroupSync

This program synchronizes Active Directory groups with CiviCRM groups. It is designed to be run as a cron job.

Installation via pipx

pipx install --include-deps --index-url https://git.propeace.de/api/packages/ProPeace/pypi/simple/ --pip-args='--extra-index-url https://pypi.org/simple/' adgroupsync

Configuration

Create a new configuration file:

adgroupsync --create-config --conf /path/to/adgroupsync_config.toml

Edit the configuration file and set the following values:

AD Configuration

  • AD.DOMAIN: The domain of the Active Directory server.
  • AD.LDAP_SERVER: List of LDAP servers to connect to.
  • AD.PARENT_GROUP: The parent group in Active Directory that contains all groups that should be synchronized.
  • AD.TIMEZONE: The timezone of the Active Directory server.
  • AD.USER: The username of the user to connect to the Active Directory server.
  • AD.PASSWORD: The password of the user to connect to the Active Directory server.

Civicrm Configuration

  • CIVICRM.API_KEY: The API key of the CiviCRM user.
  • CIVICRM.BASE_URL: The URL of the CiviCRM server.
  • CIVICRM.BATCH_SIZE: The batch size for the API requests to the CiviCRM server (only applied to contact sync). DEFAULT: 50
  • CIVICRM.RETRIES: The number of retries for the API requests to the CiviCRM server. DEFAULT: 3
  • CIVICRM.IGNORE_SSL: Allow insecure connections to the CiviCRM server. DEFAULT: False

Logging Configuration

  • LOGGING.STDOUT_LOG_LEVEL: The log level for the stdout logger. DEFAULT: INFO
  • LOGGING.FILE_LOG_LEVEL: The log level for the file logger. DEFAULT: INFO
  • LOGGING.LOG_DIR: The directory to store the log file. _DEFAULT: /var/log/adGroupSync/

NTFY (optional)

If you want to send notifications about failed syncs, you can configure ntfy.

  • NTFY.URL: The URL of the ntfy server.
  • NTFY.TOPIC: The topic to post the message to.
  • NTFY.ACCESS_TOKEN: The access token for the NTFY server.

Usage

Manual Sync

adgroupsync --conf /path/to/adgroupsync_config.toml

Cron Job

Automatically create a cron job in the user's crontab that synchronizes the groups every 10 minutes:

adgroupsync --conf /path/to/adgroupsync_config.toml --create-cron '*/10 * * * *'