Added reset password
This commit is contained in:
parent
99e46a4d1f
commit
cd2e06b74f
0
pdc-bulk-del-user.sh
Normal file → Executable file
0
pdc-bulk-del-user.sh
Normal file → Executable file
26
pdc-reset-password.sh
Executable file
26
pdc-reset-password.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
USERNAME=$1
|
||||||
|
PASSWORD=123456789
|
||||||
|
|
||||||
|
# Check if arguments are not empty
|
||||||
|
if [ -z "$USERNAME" ]; then
|
||||||
|
echo "Usage: $0 <username>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if $USERNAME exists
|
||||||
|
if ! samba-tool user show $USERNAME >/dev/null 2>&1; then
|
||||||
|
echo "User $USERNAME do not exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set user password
|
||||||
|
echo "Setting user password $PASSWORD for user $USERNAME"
|
||||||
|
|
||||||
|
# Set user password with smbpasswd, inject password and password confirmation into stdin
|
||||||
|
echo -e "$PASSWORD\n$PASSWORD" | smbpasswd -s -a $USERNAME >>/var/log/samba/smbpasswd.log 2>&1
|
||||||
|
|
||||||
|
# Force password change on next login
|
||||||
|
echo "Forcing password change on next login for user $USERNAME"
|
||||||
|
net sam set pwdmustchangenow $USERNAME yes >>/var/log/samba/smbpasswd.log 2>&1
|
Loading…
Reference in New Issue
Block a user