Skip to content

How to look up DB2 user authority (LDAP Plug-in)

30-Jan-09

If you are using the DB2 LDAP Plug-in (( See this post for some other experiences and thoughts I have had about the plug-in. )), you may wondering how to research whether your DB2 users have the authority to do their work. You will need to know that (A) they have an LDAP account and (B) they belong to the required LDAP groups to do their job, and not belong to groups that exceed their authority. Here is a quick cheatsheet on using the Unix utility ldapsearch to get this information. These examples assume you have a Unix shell session open and have the authority to run ldapsearch.

First go to your DB2 LDAP configuration file IBMLDAPSecurity.ini which will be in the <instance home directory>/sqllib/cfg directory. Look up the following variables in that text file: LDAP_HOST, USER_BASEDN and GROUP_BASEDN . The lines will look something like this:

LDAP_HOST = 10.235.1.43 10.235.173.67 10.235.173.170 10.235.44.34 10.50.1.43 10.50.50.101 10.50.60.37  10.222.71.55 10.222.68.55
USER_BASEDN = ou=people,dc=mybigcompany,dc=com
GROUP_BASEDN = ou=serverGroup,dc=mybigcompany,dc=com

With LDAP_HOST you need to pick one host from the list. Pick an active LDAP server, in this case we will use 10.235.1.43.

Now export these values for ease of use:

export MY_USER_BASEDN="ou=people,dc=mybigcompany,dc=com"
export MY_GROUP_BASEDN="ou=serverGroup,dc=mybigcompany,dc=com"
export MY_LDAP_HOST="10.235.1.43"

OK now you can run lookups on your users’ LDAP account and group membership. To see all LDAP users:

ldapsearch -b "$MY_USER_BASEDN" -h $MY_LDAP_HOST "cn=*"

If I’m not sure of the exact spelling of my user’s name, but I have part of it, I might use thus (  ‘someguy’ stands for part of your user’s name and is not case sensitive):

ldapsearch -b "$MY_USER_BASEDN" -h $MY_LDAP_HOST "cn=*someguy*"

the output would be something like:

version: 1
dn: uid=fsomeguy,ou=people,dc=mybigcompany,dc=com
shadowMin: 8
uidNumber: 10988
gidNumber: 10988
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: top
objectClass: posixAccount
objectClass: shadowAccount
objectClass: mybigcompanyEmployee
uid: jbenner
gecos: Funguy Someguy
cn: Funguy Someguy
sn: Someguy
homeDirectory: /home/fsomeguy
mail: funguy.someguy@mybigcompany.com
givenName: Funguy
securityQuestion: what is your father's middle name?:l0Han3ZdQWsMS20BF3C9bf
loginShell: /bin/ksh

Now you know the user account exists. To get the groups the user belongs to, you have to work backward from the group name. If you’re not sure, you can get all the LDAP groups with this command:

ldapsearch -b "$MY_GROUP_BASEDN" -h $MY_LDAP_HOST "cn=*"

You can get just the group names as “cn” attributes by piping the output to

grep "cn:"

Once you’ve verified the spelling of a group or groups you have an interest in, you can easily get the list of what users belong to that group. Say the group name is DB2_DBA_PRD_ROLE. The following command:

ldapsearch -b ""$MY_GROUP_BASEDN"" -h $MY_LDAP_HOST "cn=DB2_DBA_PRD_ROLE"

will give you something like:

version: 1
dn: cn=NEAT_DBA_PRD_ROLE,ou=serverGroup,dc=mybigcompany,dc=com
cn: DB2_DBA_PRD_ROLE
uniqueMember: uid=bgood,ou=people,dc=mybigcompany,dc=com
uniqueMember: uid=culater,ou=people,dc=mybigcompany,dc=com
uniqueMember: uid=dstruct,ou=people,dc=mybigcompany,dc=com
uniqueMember: uid=db2,ou=people,dc=mybigcompany,dc=com
uniqueMember: uid=elated,ou=people,dc=mybigcompany,dc=com
objectClass: groupOfUniqueNames
objectClass: top

Footnotes

Using Oracle Enterprise Manager Grid Control to Manage DB2

26-Jan-09

I posted a question on DB2-L asking other DB2 database professionals about their experiences using Oracle Enterprise Manager (OEM) Grid Control (GC) to manage DB2 databases using the OEM DB2 plug-in. I received this very helpful response from Peter Suhner ( peter_suhner AT hotmail DOT com ), posted with his permission:

yes, we do [use OEM to manage DB2 databases] – just for convenience (many Oracle DBs, only around 60 DB2 LUW instances). The DB2 Plug-in is ok, it basically grabs the values from the DB2 databases through JDBC by calling the respective admin functions (e.g. “get_dbsize_info(?,?,?,-1)” and the like – NOT the SYSIBMADM views). It provides you with about all relevant standard monitoring values. I think you could also extend these standard checks with some of your own, but I haven’t found the time to delve into this.

However, my experience is as follows:
– I’m not aware of a way to acutally manage the DB2 instances, we just monitor them through OEM. Maybe I missed something there?
– DB2 health monitoring must be turned on (not all shops like to do this for performance reasons)
– You can use the DB2 plug-in out of the box, but might want to adapt some of the standard threshold and scheduling values
– Not all the values shown in OEM are 100% reliable (e.g. Bufferpool Hit Ratio sometimes varies heavily from what native DB2 values show – looks like this is caused by OEM doing some strange maths of it’s own to various values – thus the term “Oracle”?). For our shop, these differences were found to be negligible.
– OEM database tends to become incredibly slow with growing amounts of monitoring data
– As a result, reports of one single DB usually work fine, but reports over groups (which would be a nice feature) just fail with timeouts (maybe there’s a way to tune our OEM database? But I’ve seen better data models in my life)

From my experience, I would not recommend OEM for sites with many and/or performance critical DB2 databases. However, to integrate monitoring of a few DB2 instances into an Oracle shop, this is an acceptable solution providing low overhead and one single, identical interface. Definitely a pro!

Thanks Peter! My biggest concern in reading your comments that Health Monitor would have to be active to use OEM to monitor DB2 health. As I have commented elsewhere in this blog, I have had to deactivate Health Monitor in a DB2 version 9 database due to its detrimental effect on database performance.