added smbHome to schema. SAM_ACCOUNT struct holds the UNC path
[Samba.git] / source / smbadduser
blobe4e1b273d142cc9c490addb97cebcbd4d552f4ad
1 #!/bin/csh
3 # smbadduser - Written by Mike Zakharoff
5 unalias *
6 set path = ($path /usr/local/samba/bin)
8 set smbpasswd = /usr/local/samba/private/smbpasswd
9 set user_map = /usr/local/samba/lib/users.map
11 # Set to site specific passwd command
13 #set passwd = "cat /etc/passwd"
14 #set passwd = "niscat passwd.org_dir"
15 set passwd = "ypcat passwd"
17 set line = "----------------------------------------------------------"
18 if ($#argv == 0) then
19 echo $line
20 echo "Written: Mike Zakharoff email: michael.j.zakharoff@boeing.com"
21 echo ""
22 echo " 1) Updates $smbpasswd"
23 echo " 2) Updates $user_map"
24 echo " 3) Executes smbpasswd for each new user"
25 echo ""
26 echo "smbadduser unixid:ntid unixid:ntid ..."
27 echo ""
28 echo "Example: smbadduser zak:zakharoffm johns:smithj"
29 echo $line
30 exit 1
31 endif
33 touch $smbpasswd $user_map
34 set new = ()
35 foreach one ($argv)
36 echo $one | grep ':' >& /dev/null
37 if ($status != 0) then
38 echo "ERROR: Must use unixid:ntid like -> zak:zakharoffm"
39 continue
40 endif
41 set unix = `echo $one | awk -F: '{print $1}'`
42 set ntid = `echo $one | awk -F: '{print $2}'`
44 set usr = `eval $passwd | awk -F: '$1==USR {print $1}' USR=$unix`
45 if ($#usr != 1) then
46 echo "ERROR: $unix Not in passwd database SKIPPING..."
47 continue
48 endif
49 set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix`
50 if ($#tmp != 0) then
51 echo "ERROR: $unix is already in $smbpasswd SKIPPING..."
52 continue
53 endif
55 echo "Adding: $unix to $smbpasswd"
56 eval $passwd | \
57 awk -F: '$1==USR { \
58 printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n", $1, $3, $5, $6, $7) }' USR=$unix >> $smbpasswd
59 if ($unix != $ntid) then
60 echo "Adding: {$unix = $ntid} to $user_map"
61 echo "$unix = $ntid" >> $user_map
62 endif
63 set new = ($new $unix)
64 end
67 # Enter password for new users
69 foreach one ($new)
70 echo $line
71 echo "ENTER password for $one"
72 smbpasswd $one
73 end