Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are setting up a PostgreSQL 9.1 database at work. There are no classified data in the database, but we want to know who is doing what. We are using LDAP authentification on the network, so we would like to use that for the database as well, but according to the documentation, all users anyhow need to be defined as database users.

We could of course do a "dump" of users to the database, but we would prefer if it could be possible to define users in the database as soon as they have authenticated in LDAP. This would not be too difficult using a wrapper script, but is it somehow possible to do this directly? (Most users log in using psql.)

share|improve this question

I'm not very familiar with LDAP (beware of understatement!), but I'm pretty sure there is no way to do this automatically on the PostgreSQL side. If you create your LDAP users in a GUI then probably you want to set up a cron script to export the users to the database (I don't know if you can define trigger-like behaviour there, I mean something which would fire a user-creation DB script once a user is created for LDAP). If you do this from a script then it is quite easy to solve the problem, as you already mentioned.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.