openldap PostgreSQLの認証
環境
LDAP : centos 6.4
openldap-2.4.23-32
postgres : postgres9.2
openldap-2.4.23-32
postgres : postgres9.2
LDAPサーバ側作業
なし
前回作成したtestユーザを使用する。
前回作成したtestユーザを使用する。
postgresサーバ側作業
postgresql.conf
他のホストからの接続できるようにする。
# vi postgresql.conf
# vi postgresql.conf
・・・listen_addresses = '*'・・・ |
# /etc/init.d/postgresql-9.2 restart
Stopping postgresql-9.2 service: [ OK ]
Starting postgresql-9.2 service: [ OK ]
Stopping postgresql-9.2 service: [ OK ]
Starting postgresql-9.2 service: [ OK ]
# netstat -lanput | grep 5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 5574/postmastertcp 0 0 :::5432 :::* LISTEN 5574/postmaster |
↑0 0.0.0.0:5432になっていることを確認
pg_hba.conf
# "local" is for Unix domain socket connections only#local all all peerlocal all all ldap ldapserver=192.168.122.80 ldapprefix="uid=" ldapsuffix=", ou=a_1, ou=a, dc=cse, dc=com"# IPv4 local connections:#host all all 127.0.0.1/32 identhost all all 127.0.0.1/32 ldap ldapserver=192.168.122.80 ldapprefix="uid=" ldapsuffix=", ou=a_1, ou=a, dc=cse, dc=com"# IPv6 local connections:#host all all ::1/128 identhost all all ::1/128 ldap ldapserver=192.168.122.80 ldapprefix="uid=" ldapsuffix=", ou=a_1, ou=a, dc=cse, dc=com" |
# /etc/init.d/postgresql-9.2 restart
Stopping postgresql-9.2 service: [ OK ]
Starting postgresql-9.2 service: [ OK ]
Stopping postgresql-9.2 service: [ OK ]
Starting postgresql-9.2 service: [ OK ]
postgres でユーザを作成
# su – postgres
$ createuser -P test
$ createuser -U test -P testdb
$ createuser -P test
$ createuser -U test -P testdb
正常確認
# psql -U test testdb
Password for user test:psql (9.2.4)Type "help" for help.testdb=> |
ログインできたことを確認
ldapのログを確認
# tail -f /var/log/slapd.log
# tail -f /var/log/slapd.log
Aug 29 23:49:27 ldap slapd[1075]: conn=1241 fd=29 ACCEPT from IP=192.168.122.10:59384 (IP=0.0.0.0:389)Aug 29 23:49:27 ldap slapd[1075]: conn=1241 op=0 BIND dn="uid=test,ou=a_1,ou=a,dc=cse,dc=com" method=128Aug 29 23:49:27 ldap slapd[1075]: conn=1241 op=0 BIND dn="uid=test,ou=a_1,ou=a,dc=cse,dc=com" mech=SIMPLE ssf=0Aug 29 23:49:27 ldap slapd[1075]: conn=1241 op=0 RESULT tag=97 err=0 text=Aug 29 23:49:27 ldap slapd[1075]: conn=1241 op=1 UNBINDAug 29 23:49:27 ldap slapd[1075]: conn=1241 fd=29 closed |
正常にldap認証ができたことを確認できた。
以上