Software Engineer

checking if a samba account exists

· by jsnby · Read in about 1 min · (76 Words)
Computers

If you’re using the tdbsam password backend in samba and need to check to see if a user’s account exists, you can use this command line(replace with the username of your user:

test `pdbedit -w -L | awk -F":" '{ print $1 }' | grep '<username>$' | wc -l` -eq 0 || echo "account exists"

If you’re not using the tdbsam password backend and are using the regular smbpasswd file, you can run this command instead:

test `cat smbpasswd | awk -F":" '{ print $1 }' | grep '^<username>$' | wc -l` -eq 0 || echo "account exists"