[Samba] How to test that the administrator password is correct in a script?

Patrick Goetz pgoetz at math.utexas.edu
Sat Mar 12 20:53:25 UTC 2022


I have a script which creates user accounts, makes home directories, 
adds the users to groups, etc., but I'd like to make it more elegant.

Right now if the administrator password is incorrectly entered you get a 
bunch of python errors as output.  Also, since the script runs as root, 
some steps (e.g. home directory creation) are carried out even if the 
user creation fails because the administrator password was entered 
incorrectly.

I'd like to check the correctness of the password before actually doing 
anything -- has anyone figured out a good way to do this? My thought was 
to run some command as administrator and exit if the output indicates 
that the correct data wasn't retrieved.

This problem is compounded by the fact that it appears samba-tool only 
works on a DC -- is this correct?  Whenever I try to run something like

   samba-tool user list -U administrator

on a client machine I just get a bunch of python errors.  Seems like it 
should be possible to make this tool work from anywhere in the domain.




More information about the samba mailing list