Attempting to add a (non-existant) user to my CentOS system is returning useradd: user example exists
. I can successfully manually add the user to /etc/passwd and /etc/shadow, but that workaround is A Bad Thing. The user exists in LDAP, but PAM isn't using LDAP for authentication. Adding other users works fine. I'm stumped.
ETA:
[root ~]# userdel example
userdel: error deleting password entry
userdel: error deleting shadow password entry
[root ~]# useradd example
useradd: user example exists
[root ~]# su example
bash-3.2$ whoami
example
bash-3.2$ groups example
example : Users
bash-3.2$ cd
bash: cd: /home/example: No such file or directory
bash-3.2$
Best Answer
If you include LDAP in the
/etc/nsswitch.conf
(for examplepasswd: files ldap
orpasswd:compat passwd_compat:ldap
, etc.) it is enough forgetent passwd
and thus foruseradd
to see LDAP entries.Both utilities have nothing to do with PAM, and happily recognize LDAP entries even if PAM knows nothing about LDAP.
By the way, if you have
nscd
running, remember to restart it after you changensswitch.conf
.