Sync LDAP accounts to Redmine

You can configure Redmine to use an LDAP or Active Directory server as login backend. Whenever a new user has been successfully authenticated against this service, a new entry in the Redmine's user table is created.

A side effect of this is that you can't work with users that have not logged in into your instance, yet.

To solve this I've created a small python script that can be used to periodically synchronize the users table with your directory services:

https://gist.github.com/Cybso/2d9b27589f657b057c34

Not only it creates stubs for users that WOULD be able to login into Redmine, but also disables users that are not able to login anymore.

Just create a cron job like this to update the users once a day:

0 3 * * * redmineuser /usr/local/bin/redmine-ldapsync.py /srv/redmine/config/database.yml

Comments

Hi,
i tried to run your script on Redmine 3.3.2.stable.16179
I copy the script in redmine/config
I tried to run manually via:
python redmine-ldapsync.py
but I got next error:

[root@vostro config]# python redmine-ldapsync.py
Traceback (most recent call last):
File "redmine-ldapsync.py", line 49, in
import ldap
ImportError: No module named ldap

Can you help me solving this and to import AD accounts?
Thank you in advance

You have to install Python's LDAP library. On Debian the package is called "python-ldap".

I installed it, but now I got this error:

[root@vostro config]# python redmine-ldapsync.py
Traceback (most recent call last):
File "redmine-ldapsync.py", line 50, in
import mysql.connector
ImportError: No module named mysql.connector

Your script is not working.

@Irina: What's the error message? The script's running fine for me for nearly three years now.