Active Directory PostgreSQL LDAP Konfigürasyonu ile PostgreSQL e yapılan bağlantıların LDAP protokolü kullanılarak PostgreSQL kullanıcılarının kimlik doğrulamalarının (authentication) nasıl yapılacağını göstermektedir.
Aslında PostgreSQL tarafında yapılacak işlem oldukça basit pg_hba.conf
dosyası üzerinde yapılacak konfigürasyon ile kolaylıkla bu bağlantı sağlanmaktadır.
Öncelikle active directory e connection kurabiliyormuyuz bunu bir test edelim;
$ nc -v ldap_ip_adress 389
Connection to lldap_ip_adress 389 port [tcp/ldap] succeeded!
Port:389
Service User : CN=Psadmin,OU=Users,OU=Bisoft,DC=bisoft,DC=com,DC=tr
Service Password : Password123
User Base: OU=Bisoft,DC=bisoft,DC=com,DC=tr
User Filter: (&(objectClass=person)(sAMAccountName=*))
User Attribute: sAMAccountName
User Extra Attributes: cn,uid,sn,dn,objectClass,ou
Group Base: OU=Groups,OU=Bisoft,DC=bisoft,DC=com,DC=tr
Group Filter: (&(objectClass=group)(cn=*))
Group Attribute: cn
Group Extra Attributes: cn,memberOf,ou,uid,sn,dn,objectClass,member,sAMAccountName
Yukarıdaki OU ve CN pathleri bizim için önemlidir, kuruluşumuzun doğru pathleri AD yöneticisinden temin etmemiz gerekmektedir, bunu test etmek için,
--LDAP ustil paketlerini kuralım eğer yoksa
# yum install ldap-utils
--veya ubutu, debian grubu ise
# apt-get install ldap-utils
ldapsearch -v -x -H ldap://ldap_ip_adress -b "OU=Users,OU=Bisoft,DC=bisoft,DC=com , DC=tr" -D "CN=service-account-username,OU=ServiceAccounts,OU=Users,OU=local,DC=example,DC=com" -W "(sAMAccountName=bisoft)"
--Veya uid kullanılabilir
ldapsearch -v -x -H ldap://ldap_ip_adress -b "OU=Users,OU=Bisoft,DC=bisoft,DC=com , DC=tr" -D "CN=service-account-username,OU=ServiceAccounts,OU=Users,OU=Bisoft,DC=bisoft,DC=com , DC=tr" -W "(sAMAccountName=bisoft)"
pg_hba.conf
içerisinde , sadece bisoft user için bir deneme yaptım
host all bisoft 0.0.0.0/0 ldap ldapserver=ldap_ip_adress ldapprefix="CN=" ldapsuffix=", OU=Users,OU=Bisoft,DC=bisoft,DC=com,DC=tr" ldapport=389
--veya
host all all 192.168.0.0/16 ldap ldapserver=ldap-server.example.com ldapbasedn="OU=Users,OU=Bisoft,DC=bisoft,DC=com,DC=tr" ldapbinddn="CN=service-account-username,OU=ServiceAccounts,OU=Users,OU=Bisoft,DC=bisoft,DC=com,DC=tr" ldapbindpasswd="Testing123" ldapsearchattribute="sAMAccountName"
Bağlanmak istediğimde ; öncelikle LDAP Password export edilerek set edilir sonrasında bağlantı test edilir
$ pg_ctl reload
server signaled
$ export PGPASSWORD=Password123
$ psql -h 64.227.76.123 -d postgres -U bisoft -p 5433
psql (13.8)
Type "help" for help.
----Birde hatalı password ile deneyelim
$ export PGPASSWORD=faruk123
$ psql -h 64.227.76.123 -d postgres -U bisoft -p 5433
psql: error: FATAL: LDAP authentication failed for user "bisoft"
Bir yanıt yazın