Thursday, May 06, 2010

Retrieve Information on LDAP User

Here are a couple easy methods to get information from ldap for a particular user. Friend and I were talking about it yesterday because we had a typo in someone's login directory string (missing a character). He showed me a fancy one-liner but all I needed was a username, login directory, and its corresponding UID.

# ldaplist -l password username

# getent passwd username

# logins -x | grep username

The getent command is also handy to retrieve host and group information. It consults what databases are listed in the /etc/nsswitch.conf file.

# getent hosts hostname
# getent group 100

1 comment:

Tobias said...

Long live the Unix toolbox. :) Many times obscure oneliners in $scriptinglanguageoftheday are indeed not necessary, the toolbox does the job.

beardy's thoughts, more or less unorganized