8

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?

Harinder
  • 205

1 Answers1

9

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

mtak
  • 17,262