#!/bin/bash
# Samba-TNG                                                 set_passwd
# --------------------------------------------------------------------

# --------------------------------------------------------------------
# config here

. ./prefs

# --------------------------------------------------------------------

# print usage

if [ "$2" == "" ]; then
        echo "Usage: $(basename $0) <user> <passwd>"
        exit 0
fi

# --------------------------------------------------------------------
# begin

myuser=`ldapsearch -D $binddn -w $bindpassword -b $smbsuffix ntuid="$1" -LLL|grep dn:`
echo $myuser

if [ "$myuser" == "" ]; then
	echo "User not known!"
	exit 1
fi

rpcclient -U $rpcuser%$rpcpassword -S . -c "samuserset2 \"$1\" -p \"$2\" " -d0

exit 0

# --------------------------------------------------------------------
