Reset LDAP server in Redmine sqlite database

Our Redmine instance authenticates users against our institute’s LDAP server. The other day they moved the LDAP service to a new machine and the IP changed, which locked us out of Redmine. If this happens to you, you can easily change the LDAP server in the Redmine database. We’re using sqlite, but the concept should be the same for other database backends Redmine supports.

This sqlite statement says it all:

sqlite> update auth_sources set host="172.26.0.11" where id=1;

Longer version

Here’s a little more background…

Assuming your Redmine instance is in /opt/redmine, your sqlite database should be /opt/redmine/db/redmine.db. Become root, and then move into your Redmine directory:

$ sudo su -
# cd /opt/redmine

Open the database and then turn headers on so we can investigate the database in a little more detail:

# sqlite3 db/redmine.db
sqlite> .headers on

From looking at the list of tables (.tables), it’s pretty obvious that the authentication is configured in auth_sources.

sqlite> select * from auth_sources;
id|type|name|host|port|account|account_password|base_dn|attr_login|attr_firstname|attr_lastname|attr_mail|onthefly_register|tls
1|AuthSourceLdap|Example Active Directory|172.26.0.218|389|example\aorth|imsosexy|dc=example,dc=org|sAMAccountName|givenName|sn|mail|t|f

The LDAP server’s IP is listed under the host column, so we just need to update it:

sqlite> update auth_sources set host="172.26.0.11" where id=1;

Now we can see that the IP has changed:

sqlite> select * from auth_sources;
id|type|name|host|port|account|account_password|base_dn|attr_login|attr_firstname|attr_lastname|attr_mail|onthefly_register|tls
1|AuthSourceLdap|Example Active Directory|172.26.0.11|389|example\aorth|imsosexy|dc=example,dc=org|sAMAccountName|givenName|sn|mail|t|f

… and hopefully Redmine will let you log in now!