1

I would like to automate a check (in shells script) that verifies whether the account that is currently logged in is a local account or whether it authenticates via LDAP.

Since there are various LDAP clients for different Linux / Unix flavors, I was wondering whether there is a definite method to verify that across all / most Linux / Unix-flavors (e.g. checking whether /etc/ldap/ldap.conf is configured correctly).

1

To check if the current account is an LDAP account, you can use w:

[root@hostname.domain.com /]# w
 17:09:30 up 2 days,  4:49,  2 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
DOMAIN.C pts/0    192.168.10.11  17:08    2.00s  0.07s  0.21s sshd: user@domain.com [priv]
root     pts/1    192.168.10.11  17:09   20.00s  0.01s  0.01s -bash

Notice that the domain user listed is different than the local root user.

To check if LDAP is configured properly on all systems, setup a test LDAP account and try to login to each server with those credentials.

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.