[Samba] How to test that the administrator password is correct in a script?
Rowland Penny
rpenny at samba.org
Mon Mar 14 15:33:46 UTC 2022
On Mon, 2022-03-14 at 09:23 -0500, Patrick Goetz via samba wrote:
> Since this took longer than I thought to get right, I'm sharing the
> bash
> shell snippet used to test that the Administrator password the
> script
> user entered is correct before proceeding. I looked at Roland's
> thing,
> but this seemed simpler:
>
> ($DATASERVER can be any old computer bound to the domain)
> -------------------------------------------------------------------
> ---
> read -s -p "Administrator Password: " APASS
> echo
>
> PWCHECK=$(samba-tool computer show $DATASERVER
> --attributes=sAMAccountName -H ldap://samba-dc -U
> "administrator%${APASS}" 2>&1)
>
> PWCHECK=${PWCHECK:0:2}
>
> if [ "${PWCHECK}" != "dn" ]; then
> echo "Administrator password is incorrect"
> exit 1
> fi
Yes, it is simpler, but your way is sending Administrators password
over the wire, mine doesn't.
Rowland
More information about the samba
mailing list