- Technology stack
- Architecture of the Solution
- Installing and Configuring MULTIDIRECTORY
- Configuring Kerberos in the MULTIDIRECTORY Web Interface
- Configuring DNS in the MULTIDIRECTORY Web Interface
- DHCP Configuration
- Domain Trust Configuration
- Group Policy
- Connecting MULTIFACTOR Self-Service Portal to MULTIDIRECTORY
- User, Group, and Resource Management
- Connecting to MULTIFACTOR
- Access Policies
- LDAP Schema
- LDAP Logging Configuration
- Password Policies
- Role and Permission Configuration
- LDAP Authentication in Ansible AWX
- LDAP Authentication in ArgoCD
- LDAP Authentication in GitLab
- LDAP Authentication in GitFlic
- LDAP Authentication in Jenkins
- LDAP Authentication in Harbor
- LDAP Authentication in Nexus
- LDAP Authentication in PostgreSQL
- LDAP Authentication in Rancher
- LDAP Authentication in Proxmox VE
- LDAP Authentication in SpaceVM
- LDAP Authentication in Tantor
- LDAP Authentication in Shturval
- LDAP Authentication in zVirt
- LDAP Authentication in GLPI
LDAP Authentication Setup Guide for PostgreSQL
Overview
This article explains how to configure LDAP authentication in PostgreSQL, using MULTIDIRECTORY as the identity provider.
To integrate PostgreSQL with MULTIDIRECTORY, create a dedicated service account in MULTIDIRECTORY with read-only access to the directory. PostgreSQL will use this account to bind to the LDAP server and authenticate users during login.
Prerequisites
- Installed MULTIDIRECTORY directory service
- Deployed PostgreSQL database system
Preparation
- Create a dedicated service account in MULTIDIRECTORY with read-only permissions to the directory. PostgreSQL will use this account to query user information during LDAP authentication.
- Create access groups in MULTIDIRECTORY for PostgreSQL users to support role-based access control.
PostgreSQL Configuration
To configure LDAP authentication, edit the PostgreSQL configuration file and follow these steps:
nano /etc/postgresql/<version>/main/pg_hba.conf
Minimum PostgreSQL Server Configuration for LDAP Authentication
# Database administrative login by Unix domain socket local all postgres peer # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only # Local socket connections - use peer for system users, md5 for password auth local all all md5 # IPv4 local connections: LDAP authentication host all all 127.0.0.1/32 ldap ldapserver=192.168.1.2 ldapbasedn="cn=users,dc=md,dc=loc" ldapbinddn="cn=admin,cn=users,dc=md,dc=loc" ldapbindpasswd="Password" ldapsearchattribute=sAMAccountName # IPv6 local connections: LDAP authentication host all all ::1/128 ldap ldapserver=192.168.1.2 ldapbasedn="cn=users,dc=md,dc=loc" ldapbinddn="cn=admin,cn=users,dc=md,dc=loc" ldapbindpasswd="Password" ldapsearchattribute=sAMAccountName # Allow replication connections from localhost, by a user with the # replication privilege. local replication all peer host replication all 127.0.0.1/32 scram-sha-256 host replication all ::1/128 scram-sha-256 # External connections: LDAP authentication host all all 0.0.0.0/0 ldap ldapserver=192.168.1.2 ldapbasedn="cn=users,dc=md,dc=loc" ldapbinddn="cn=admin,cn=users,dc=md,dc=loc" ldapbindpasswd="Password" ldapsearchattribute=sAMAccountName
Field Descriptions
- ldapserver — the hostname or IP address of your MULTIDIRECTORY LDAP server
- ldapbasedn — the base Distinguished Name (DN) from which PostgreSQL begins searching for users
- ldapbinddn — The Distinguished Name (DN) of the service account with read-only access to the directory
- ldapbindpasswd — The password for the service account specified in ldapbinddn.
- ldapsearchattribute — The LDAP attribute used to match the username provided during login
After updating the pg_hba.conf file, reload or restart the PostgreSQL service to apply the changes
sudo systemctl reload postgresql
Test the connection by logging in to PostgreSQL using a user account from MULTIDIRECTORY.
psql -U test -d postgres -h localhost -W # test - учетная запись в каталоге
Field Descriptions
- -U — Specifies the username from MULTIDIRECTORY to authenticate with.
- -d — The name of the PostgreSQL database to connect to.
- -h — The IP address or hostname of the server where PostgreSQL is running.
- -W — Prompts for the password of the MULTIDIRECTORY user specified with -U.