LdavSync is a corporate directory application with automatic LDAP synchronization, centralized group phone numbers, and CardDAV protocol support for Thunderbird and external clients.
- โจ Automatic LDAP Sync: Hourly synchronization of contacts from LDAP directory
- ๐ Group Numbers: Centralized management of group phone numbers (e.g., Reception, Protocol Office)
- ๐ Live Search: Google Contacts-style search with HTMX
- ๐ฑ CardDAV Server: Native integration with Thunderbird, iOS, Android
- ๐ Multilingual: Italian and English interface
- ๐ LDAP Authentication: Secure admin access with LDAP credentials
- ๐ณ Single Container: Easy deployment with Docker/Podman
- ๐พ Embedded SQLite: Zero-configuration database
# Clone repository
git clone https://github.com/mirkochipdotcom/ldavsync.git
cd ldavsync
# Copy and configure environment
cp .env.example .env
nano .env # Edit LDAP settings
# Start service
docker compose up -d
# Check logs
docker compose logs -fAccess the application at http://localhost:8080
# Build image
podman build -t ldavsync:latest .
# Run container
podman run -d \
--name ldavsync \
-p 8080:8080 \
-v ./data:/data:Z \
--env-file .env \
ldavsync:latestAll configuration is via environment variables (.env file):
| Variable | Description | Example |
|---|---|---|
LDAP_HOST |
LDAP server URL | ldap://ldap.example.com:389 |
LDAP_BASE_DN |
Base DN for searches | dc=example,dc=com |
LDAP_BIND_DN |
Service account DN | cn=admin,dc=example,dc=com |
LDAP_BIND_PASSWORD |
Service account password | secret |
ADMIN_USERS |
Admin usernames (; separated) |
admin;mario.rossi |
SYNC_INTERVAL_HOURS |
Sync frequency (hours) | 1 |
PRIMARY_NUMBER_PREFIX_TEMPLATE |
Phone number template | 0854321{ext} |
SESSION_SECRET |
Session encryption key | Random string |
See .env.example for complete configuration.
ldavsync/
โโโ cmd/server/ # Main application
โ โโโ main.go
โโโ internal/ # Internal packages
โ โโโ config/ # Configuration
โ โโโ database/ # SQLite operations
โ โโโ ldap/ # LDAP auth & sync
โ โโโ phonebook/ # Business logic
โ โโโ carddav/ # CardDAV protocol
โ โโโ i18n/ # Internationalization
โโโ web/ # Frontend assets
โ โโโ templates/ # HTML templates
โ โโโ static/ # CSS, JS
โโโ Dockerfile # Multi-stage build
โโโ compose.yml # Docker Compose
- Search: Available at
/- no authentication required - Contact Details: Click on any contact to view full details
- Export vCard: Download individual contacts as
.vcffiles
- Login at
/loginwith LDAP credentials - Configure primary number prefix template
- Manage group numbers (create, edit, delete)
- Associate contacts with groups
- Override contact information manually
- Trigger manual LDAP sync
- Go to Address Book
- File โ New โ CardDAV Address Book
- Enter:
- URL:
http://your-server:8080/carddav/ - Username: Your LDAP username
- Password: Your LDAP password
- URL:
- Click Continue
- Settings โ Contacts โ Accounts โ Add Account โ Other
- Select CardDAV Account
- Enter:
- Server:
your-server:8080 - Username: Your LDAP username
- Password: Your LDAP password
- Server:
- Save
For Android, use a CardDAV-compatible app like DAVxโต:
- Install DAVxโต from Play Store
- Add new account โ CardDAV
- Enter server URL and credentials
- Go 1.22+
- Docker/Podman (optional)
- LDAP server for testing
# Install dependencies
go mod download
# Run locally
cp .env.example .env
# Edit .env with your LDAP settings
go run cmd/server/main.go
# Build
go build -o ldavsync cmd/server/main.go
# Run tests
go test ./...
# Build with version tag
docker build --build-arg VERSION=0.1.0 -t ldavsync:0.1.0 .
# Run
docker run -p 8080:8080 -v $(pwd)/data:/data --env-file .env ldavsync:0.1.0GET /- Main phonebook interfaceGET /search?q={query}- Search contacts (HTMX partial)GET /contacts- List contacts (JSON)GET /contacts/{uid}- Contact detailsGET /contacts/{uid}/export- Export vCardGET /health- Health check
POST /admin/sync- Trigger manual syncGET/POST /admin/config- Manage configurationGET/POST /admin/groups- Manage groupsGET /admin/groups/{id}/members- View group membersPOST /admin/groups/{id}/members- Add memberPOST /admin/contacts/{uid}/override- Override contact data
PROPFIND /carddav/- List address bookREPORT /carddav/- Query contactsGET /carddav/{uid}.vcf- Get vCardGET /.well-known/carddav- Discovery
Check logs:
docker compose logs -f ldavsyncLook for [SYNC] entries. Common issues:
- Incorrect
LDAP_BASE_DN - Service account permissions
- Firewall blocking LDAP port
Ensure:
- LDAP authentication is working (test with web login)
- LDAP credentials are correct
- Server is reachable from client
Check:
- Volume permissions:
chown -R 1001:1001 ./data - No multiple instances accessing same database
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
MIT License - see LICENSE file for details
Built with:
- Go programming language
- gorilla/mux HTTP router
- HTMX dynamic HTML
- Tailwind CSS styling
- go-ldap LDAP client
For issues and questions:
- GitHub Issues: github.com/mirkochipdotcom/ldavsync/issues
- Documentation: See docs/ folder
Made with โค๏ธ by mirkochipdotcom