6

I have configured an LDAP client on my Linux machine. I am able to use su - myldapuser and use it. I just want to know, can I list all my LDAP users on this machine?

Referring to this link: How to get Linux users list from LDAP

I tried the "getent passwd" command, but it didn't list the users. So my question is, should this command list the users on client machine also, or will this only work on the LDAP server?

8
  • What is 'linux m/c'? – mtak Aug 5 '14 at 12:32
  • linux machine.. – Harinder Aug 5 '14 at 12:35
  • 1
    That's a pretty uncommon abbreviation :) Did you set up /etc/nsswitch.conf correctly (users: files ldap)? And what distro are you using? – mtak Aug 5 '14 at 12:37
  • I am using Centos 6, and connecting to OpenLDAP – Harinder Aug 5 '14 at 12:40
  • I referred this link: suresh-chandra.blogspot.in/2013/08/….. And there were no changes required in /etc/nsswitch.conf.. According to the link – Harinder Aug 5 '14 at 12:42
8

You should be able to list the LDAP users using getent passwd. However, in order for the system libraries to use LDAP you need to set up /etc/nsswitch.conf and the nscd and nslcd daemons. This was discussed in chat, and the following config worked for the questioner:

/etc/nslcd.conf:

uid nslcd
gid ldap
# This comment prevents repeated auto-migration of settings.
uri ldap://ldap.dg.com
base dc=dg,dc=com
ssl start_tls
tls_cacertdir /etc/openldap/cacerts

(Make sure your LDAP server supports anonymous binds, otherwise you'll need to configure nslcd to use bind credentials)

/etc/nsswitch.conf

passwd: files ldap
shadow: files ldap
group: files ldap

After a restart of the nscd and nslcd services he was able to use getent passwd to list the LDAP users

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.