#!/bin/sh
################################################################################
#                                  makesmbAcc                                  #
################################################################################
#
# Maximilian Wilhelm <max@skolelinux.de>
#
# Last changed Sun, 24 Aug 2003 19:25:23 +0200
#

# specify path to smbpasswd file
SMBPWD=""

################################################################################

if [ -z ${SMBPWD} ]; then
	echo "Specify the path to your smbpasswd file in $0."
	exit 1;
fi

if [ -z "$( grep $1 ${SMBPWD} )" ]; then
	echo "Error: User not listed in ${SMBPWD}."
	exit 1;
fi

# temporary variables
USERID=$1
LMPW=$(grep $USERID $SMBPWD | cut -d: -f3 )
NTPW=$(grep $USERID $SMBPWD | cut -d: -f4 )


# creata a samba account and set dummy password
smbpasswd -a $USERID foo


# Reset samba passwords to given hashes
cat << EOF | ldapmodify -x -h localhost -W -D cn=admin,ou=ldap-access,dc=skole,dc=skolelinux,dc=no
dn: uid=${USERID},ou=people,dc=skole,dc=skolelinux,dc=no
sambaNTPassword: $NTPW
sambaLMPassword: $LMPW
EOF
