SlideShare a Scribd company logo
Centralising Authorization in PostgreSQL
Experimenting with LDAP synchronization
Structure of this talk…
 A summary of my experience with implementing a simple
form of Centralized Authorisation
 A step by step approach
Authentication versus Authorisation
PostgreSQL LDAP Authentication
ldap ldapserver=servername.ad.company.au ldaptls=1
ldapbasedn="ou=AU,dc=ad,dc=company,dc=au" ldapbinddn="cn=Gary
Evans,ou=consultant,ou=ThirdParty Contractors,ou=Users,
ou=AU,dc=ad,dc=corelogic,dc=asia" ldapbindpasswd="<the password>"
ldapsearchattribute=sAMAccountName
Benefits of a centralized approach
 Single point of control of
database users
 Adding a user can be done by
help desk
 Less error prone
Synchronisation Approach
StarOne
DBROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
privileges
Synchronisation Approach
Server
StarOne
DBROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
privileges
ldapsearch -Z -LLL -h ldapservername -D
gevans@ldapservername -w password
-b dc=ad,dc=companyname,dc=aus
'(&(objectClass=user)(memberOf=CN='"${ADRow[0]}"'
,OU=SQL,OU=Groups,OU=AU,DC=ad,DC=ccompany
name,DC=aus))' sAMAccountName |
sed -e 's/sAMAccountName: ([a-zA-Z]*)/1/;tx;d;:x'
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Members
Groups
ROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Members
Groups
ROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Server
Members
Groups
ROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
ID Hostname Dbname ADGroup Dbrole Enabled CRUD
1 Serverone AppOne DB_Report Read_only True F,T,F,F
2 Serverone StarOne DB_Report Reporting True F,T,T,F
3 Serverone AppOne DB_Admin Admin_user True T,T,T,T
4 Serverone StarOne DB_Analysts Analyst True F,T,F,F
5
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Server
Members
Groups
ROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
ID Hostname Dbname ADGroup Dbrole Enabled CRUD
1 Serverone AppOne DB_Report Read_only True F,T,F,F
2 Serverone StarOne DB_Report Reporting True F,T,T,F
3 Serverone AppOne DB_Admin Admin_user True T,T,T,T
4 Serverone StarOne DB_Analysts Analyst True F,T,F,F
5
${PSQL} ${DBMONITOR//HOST/localhost}/schemaname -qtAX --field-separator ' ' 
-c "SELECT distinct adgroup FROM mapping WHERE enabled = true and hostname='${hostname}'" |
while read -a ADRow ; do
for adname in $(ldapsearch -Z -LLL -h ldapservername -D gevans@ldapservername -w password -b
dc=ad,dc=companyname,dc=aus
'(&(objectClass=user)(memberOf=CN='"${ADRow[0]}"',OU=SQL,OU=Groups,OU=AU,DC=ad,DC=companyna
me,DC=aus))' sAMAccountName | sed -e 's/sAMAccountName: ([a-zA-Z]*)/1/;tx;d;:x')
do
${PSQL} ${PGMONITOR//HOST/$hostname}/ schemaname -qtAX --field-separator ' '
-c "CREATE ROLE ${adname} with LOGIN;“
${PSQL} ${PGMONITOR//HOST/localhost}/ schemaname -qtAX --field-separator ' ' 
-c "SELECT distinct dbrole FROM mapping where enabled = true and
hostname='${hostname}'" and adgroup = '${adname}' | while read -a DBRRow ; do
${PSQL} ${PGMONITOR//HOST/$hostname}/performance -qtAX --field-separator ' '
-c "GRANT ${DBRRow} TO ${adname};"
done
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Server
Members
Groups
ROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
ID Hostname Dbname ADGroup Dbrole Enabled CRUD
1 Serverone AppOne DB_Report Read_only True F,T,F,F
2 Serverone StarOne DB_Report Reporting True F,T,T,F
3 Serverone AppOne DB_Admin Admin_user True T,T,T,T
4 Serverone StarOne DB_Analysts Analyst True F,T,F,F
5
${PSQL} ${DBMONITOR//HOST/localhost}/schemaname -qtAX --field-separator ' ' 
-c "SELECT distinct adgroup FROM mapping WHERE enabled = true and hostname='${hostname}'" |
while read -a ADRow ; do
for adname in $(ldapsearch -Z -LLL -h ldapservername -D gevans@ldapservername -w password -b
dc=ad,dc=companyname,dc=aus
'(&(objectClass=user)(memberOf=CN='"${ADRow[0]}"',OU=SQL,OU=Groups,OU=AU,DC=ad,DC=ccompanyn
ame,DC=aus))' sAMAccountName | sed -e 's/sAMAccountName: ([a-zA-Z]*)/1/;tx;d;:x')
do
${PSQL} ${PGMONITOR//HOST/$hostname}/ schemaname -qtAX --field-separator ' '
-c "CREATE ROLE ${adname} with LOGIN;“
${PSQL} ${PGMONITOR//HOST/localhost}/performance -qtAX --field-separator ' ' 
-c "SELECT distinct dbrole FROM mapping where enabled = true and
hostname='${hostname}'" and adgroup = '${adname}' | while read -a DBRRow ; do
${PSQL} ${PGMONITOR//HOST/$hostname}/ schemaname -qtAX --field-separator ' '
-c "GRANT ${DBRRow} TO ${adname};"
done
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Members
Groups
ROLES
postgres
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Members
Groups
ROLES
Postgres (SU)
appOneOwner (SU)
StarOneOwner (SU)
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
Owner
Owner
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Members
Groups ROLES
Postgres (SU)
appOneOwner (SU)
StarOneOwner (SU)
DB_Report (NL)
DB_Admin (NL)
DB_Analysts (NL)
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
Owner
Owner
Role
inheritance
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Members
Groups ROLES
Postgres (SU)
appOneOwner (SU)
StarOneOwner (SU)
DB_Report (NL)
DB_Admin (NL)
DB_Analysts (NL)
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
Owner
Owner
Role
inheritance
Synchronisation Approach
Database
DB_Report
DB_Admin
DB_Analysts
Andrew Smith
Bob Brown
Jenny Reid
Andrew Smith
Julie Benson
Annette Huntly
Paul Brown
Andrew Smith
Bob Brown
Jenny Reid
Members
Groups ROLES
Postgres (SU)
appOneOwner (SU)
StarOneOwner (SU)
DB_Report (NL)
DB_Admin (NL)
DB_Analysts (NL)
Andrew Smith
Bob Brown
Jenny Reid
Julie Benson
Annette Huntly
Paul Brown
AppOne DB
StarOne
DB
Owner
Owner
Role
inheritance
Existing tool
Pg-ldap-sync

More Related Content

PDF
How to teach an elephant to rock'n'roll
PDF
Modern query optimisation features in MySQL 8.
PDF
Flexible Indexing with Postgres
 
ODP
Msql
PPT
15 Ways to Kill Your Mysql Application Performance
PDF
Agile Database Development with JSON
PDF
Writing A Foreign Data Wrapper
PDF
Data Exploration with Apache Drill: Day 1
How to teach an elephant to rock'n'roll
Modern query optimisation features in MySQL 8.
Flexible Indexing with Postgres
 
Msql
15 Ways to Kill Your Mysql Application Performance
Agile Database Development with JSON
Writing A Foreign Data Wrapper
Data Exploration with Apache Drill: Day 1

What's hot (20)

PDF
Advanced pg_stat_statements: Filtering, Regression Testing & more
PDF
QB Into the Box 2018
PDF
Centralising Authorisation in PostgreSQL
PDF
PerlApp2Postgresql (2)
PDF
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...
PDF
MySQL innoDB split and merge pages
PDF
PDF
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
PPTX
Oracle Database 12.1.0.2 New Features
PDF
Stefan Hochdörfer - The NoSQL Store everyone ignores: PostgreSQL - NoSQL matt...
PDF
Accessing Databases from R
PDF
PGDay UK 2016 -- Performace for queries with grouping
ODP
Chetan postgresql partitioning
PDF
How to Use JSON in MySQL Wrong
PDF
Administering and Monitoring SolrCloud Clusters
PDF
Mongodb replication
PDF
15 MySQL Basics #burningkeyboards
PDF
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
TXT
Quick reference for mongo shell commands
ODP
Beyond PHP - It's not (just) about the code
Advanced pg_stat_statements: Filtering, Regression Testing & more
QB Into the Box 2018
Centralising Authorisation in PostgreSQL
PerlApp2Postgresql (2)
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...
MySQL innoDB split and merge pages
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Oracle Database 12.1.0.2 New Features
Stefan Hochdörfer - The NoSQL Store everyone ignores: PostgreSQL - NoSQL matt...
Accessing Databases from R
PGDay UK 2016 -- Performace for queries with grouping
Chetan postgresql partitioning
How to Use JSON in MySQL Wrong
Administering and Monitoring SolrCloud Clusters
Mongodb replication
15 MySQL Basics #burningkeyboards
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
Quick reference for mongo shell commands
Beyond PHP - It's not (just) about the code
Ad

Similar to PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL (20)

PDF
Bag Of Tricks From Iusethis
PPTX
Windows power shell and active directory
PDF
Using OpenFire With OpenLDAP
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
PDF
Service discovery and configuration provisioning
PDF
Why is crud a bad idea - focus on real scenarios
PDF
FamilySearch Reference Client
PPT
XQuery Triggers in Native XML Database Sedna
PPT
Framework
KEY
Zend Framework Study@Tokyo #2
PDF
WordPress REST API hacking
KEY
About Data::ObjectDriver
PDF
Creating and Maintaining WordPress Plugins
PPTX
Drupal II: The SQL
KEY
Api Design
PDF
Doctrine For Beginners
PPTX
Application Stack - TIAD Camp Microsoft Cloud Readiness
PDF
Redis for your boss
PDF
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Bag Of Tricks From Iusethis
Windows power shell and active directory
Using OpenFire With OpenLDAP
Burn down the silos! Helping dev and ops gel on high availability websites
Service discovery and configuration provisioning
Why is crud a bad idea - focus on real scenarios
FamilySearch Reference Client
XQuery Triggers in Native XML Database Sedna
Framework
Zend Framework Study@Tokyo #2
WordPress REST API hacking
About Data::ObjectDriver
Creating and Maintaining WordPress Plugins
Drupal II: The SQL
Api Design
Doctrine For Beginners
Application Stack - TIAD Camp Microsoft Cloud Readiness
Redis for your boss
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Ad

More from PGConf APAC (20)

PDF
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PDF
PGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PDF
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PDF
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
PDF
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PDF
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PDF
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PDF
PGConf APAC 2018 - Monitoring PostgreSQL at Scale
PDF
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PDF
PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBo...
PDF
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PDF
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PDF
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
PDF
PGConf APAC 2018 - Tale from Trenches
PDF
PGConf APAC 2018 Keynote: PostgreSQL goes eleven
PDF
Amazon (AWS) Aurora
PDF
Use Case: PostGIS and Agribotics
PDF
PostgreSQL on Amazon RDS
PDF
PostgreSQL WAL for DBAs
PDF
Lightening Talk - PostgreSQL Worst Practices
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - Monitoring PostgreSQL at Scale
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBo...
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
PGConf APAC 2018 - Tale from Trenches
PGConf APAC 2018 Keynote: PostgreSQL goes eleven
Amazon (AWS) Aurora
Use Case: PostGIS and Agribotics
PostgreSQL on Amazon RDS
PostgreSQL WAL for DBAs
Lightening Talk - PostgreSQL Worst Practices

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
KodekX | Application Modernization Development
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The AUB Centre for AI in Media Proposal.docx
KodekX | Application Modernization Development
MIND Revenue Release Quarter 2 2025 Press Release
MYSQL Presentation for SQL database connectivity
Programs and apps: productivity, graphics, security and other tools
Spectral efficient network and resource selection model in 5G networks
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Building Integrated photovoltaic BIPV_UPV.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Review of recent advances in non-invasive hemoglobin estimation
20250228 LYD VKU AI Blended-Learning.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL

  • 1. Centralising Authorization in PostgreSQL Experimenting with LDAP synchronization
  • 2. Structure of this talk…  A summary of my experience with implementing a simple form of Centralized Authorisation  A step by step approach
  • 3. Authentication versus Authorisation PostgreSQL LDAP Authentication ldap ldapserver=servername.ad.company.au ldaptls=1 ldapbasedn="ou=AU,dc=ad,dc=company,dc=au" ldapbinddn="cn=Gary Evans,ou=consultant,ou=ThirdParty Contractors,ou=Users, ou=AU,dc=ad,dc=corelogic,dc=asia" ldapbindpasswd="<the password>" ldapsearchattribute=sAMAccountName
  • 4. Benefits of a centralized approach  Single point of control of database users  Adding a user can be done by help desk  Less error prone
  • 6. Synchronisation Approach Server StarOne DBROLES postgres Andrew Smith Bob Brown Jenny Reid Julie Benson privileges ldapsearch -Z -LLL -h ldapservername -D gevans@ldapservername -w password -b dc=ad,dc=companyname,dc=aus '(&(objectClass=user)(memberOf=CN='"${ADRow[0]}"' ,OU=SQL,OU=Groups,OU=AU,DC=ad,DC=ccompany name,DC=aus))' sAMAccountName | sed -e 's/sAMAccountName: ([a-zA-Z]*)/1/;tx;d;:x'
  • 7. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Members Groups ROLES postgres Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB
  • 8. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Members Groups ROLES postgres Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB
  • 9. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Server Members Groups ROLES postgres Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB ID Hostname Dbname ADGroup Dbrole Enabled CRUD 1 Serverone AppOne DB_Report Read_only True F,T,F,F 2 Serverone StarOne DB_Report Reporting True F,T,T,F 3 Serverone AppOne DB_Admin Admin_user True T,T,T,T 4 Serverone StarOne DB_Analysts Analyst True F,T,F,F 5
  • 10. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Server Members Groups ROLES postgres Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB ID Hostname Dbname ADGroup Dbrole Enabled CRUD 1 Serverone AppOne DB_Report Read_only True F,T,F,F 2 Serverone StarOne DB_Report Reporting True F,T,T,F 3 Serverone AppOne DB_Admin Admin_user True T,T,T,T 4 Serverone StarOne DB_Analysts Analyst True F,T,F,F 5 ${PSQL} ${DBMONITOR//HOST/localhost}/schemaname -qtAX --field-separator ' ' -c "SELECT distinct adgroup FROM mapping WHERE enabled = true and hostname='${hostname}'" | while read -a ADRow ; do for adname in $(ldapsearch -Z -LLL -h ldapservername -D gevans@ldapservername -w password -b dc=ad,dc=companyname,dc=aus '(&(objectClass=user)(memberOf=CN='"${ADRow[0]}"',OU=SQL,OU=Groups,OU=AU,DC=ad,DC=companyna me,DC=aus))' sAMAccountName | sed -e 's/sAMAccountName: ([a-zA-Z]*)/1/;tx;d;:x') do ${PSQL} ${PGMONITOR//HOST/$hostname}/ schemaname -qtAX --field-separator ' ' -c "CREATE ROLE ${adname} with LOGIN;“ ${PSQL} ${PGMONITOR//HOST/localhost}/ schemaname -qtAX --field-separator ' ' -c "SELECT distinct dbrole FROM mapping where enabled = true and hostname='${hostname}'" and adgroup = '${adname}' | while read -a DBRRow ; do ${PSQL} ${PGMONITOR//HOST/$hostname}/performance -qtAX --field-separator ' ' -c "GRANT ${DBRRow} TO ${adname};" done
  • 11. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Server Members Groups ROLES postgres Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB ID Hostname Dbname ADGroup Dbrole Enabled CRUD 1 Serverone AppOne DB_Report Read_only True F,T,F,F 2 Serverone StarOne DB_Report Reporting True F,T,T,F 3 Serverone AppOne DB_Admin Admin_user True T,T,T,T 4 Serverone StarOne DB_Analysts Analyst True F,T,F,F 5 ${PSQL} ${DBMONITOR//HOST/localhost}/schemaname -qtAX --field-separator ' ' -c "SELECT distinct adgroup FROM mapping WHERE enabled = true and hostname='${hostname}'" | while read -a ADRow ; do for adname in $(ldapsearch -Z -LLL -h ldapservername -D gevans@ldapservername -w password -b dc=ad,dc=companyname,dc=aus '(&(objectClass=user)(memberOf=CN='"${ADRow[0]}"',OU=SQL,OU=Groups,OU=AU,DC=ad,DC=ccompanyn ame,DC=aus))' sAMAccountName | sed -e 's/sAMAccountName: ([a-zA-Z]*)/1/;tx;d;:x') do ${PSQL} ${PGMONITOR//HOST/$hostname}/ schemaname -qtAX --field-separator ' ' -c "CREATE ROLE ${adname} with LOGIN;“ ${PSQL} ${PGMONITOR//HOST/localhost}/performance -qtAX --field-separator ' ' -c "SELECT distinct dbrole FROM mapping where enabled = true and hostname='${hostname}'" and adgroup = '${adname}' | while read -a DBRRow ; do ${PSQL} ${PGMONITOR//HOST/$hostname}/ schemaname -qtAX --field-separator ' ' -c "GRANT ${DBRRow} TO ${adname};" done
  • 12. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Members Groups ROLES postgres Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB
  • 13. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Members Groups ROLES Postgres (SU) appOneOwner (SU) StarOneOwner (SU) Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB Owner Owner
  • 14. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Members Groups ROLES Postgres (SU) appOneOwner (SU) StarOneOwner (SU) DB_Report (NL) DB_Admin (NL) DB_Analysts (NL) Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB Owner Owner Role inheritance
  • 15. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Members Groups ROLES Postgres (SU) appOneOwner (SU) StarOneOwner (SU) DB_Report (NL) DB_Admin (NL) DB_Analysts (NL) Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB Owner Owner Role inheritance
  • 16. Synchronisation Approach Database DB_Report DB_Admin DB_Analysts Andrew Smith Bob Brown Jenny Reid Andrew Smith Julie Benson Annette Huntly Paul Brown Andrew Smith Bob Brown Jenny Reid Members Groups ROLES Postgres (SU) appOneOwner (SU) StarOneOwner (SU) DB_Report (NL) DB_Admin (NL) DB_Analysts (NL) Andrew Smith Bob Brown Jenny Reid Julie Benson Annette Huntly Paul Brown AppOne DB StarOne DB Owner Owner Role inheritance