checking if a samba account exists
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
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"