Setting account policy values is done using -C, not -V. Fixes bug #120
[Samba/gebeck_regimport.git] / source3 / smbadduser
blob9837413aeb5ac0613d07953f4db2afc630483c1a
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 smbpasswd = /etc/samba/smbpasswd
10 set user_map = /usr/local/samba/lib/users.map
11 #set user_map = /etc/samba/smbusers
13 # Set to site specific passwd command
15 set passwd = "cat /etc/passwd"
16 #set passwd = "niscat passwd.org_dir"
17 #set passwd = "ypcat passwd"
19 set line = "----------------------------------------------------------"
20 if ($#argv == 0) then
21 echo $line
22 echo "Written: Mike Zakharoff email: michael.j.zakharoff@boeing.com"
23 echo ""
24 echo " 1) Updates $smbpasswd"
25 echo " 2) Updates $user_map"
26 echo " 3) Executes smbpasswd for each new user"
27 echo ""
28 echo "smbadduser unixid:ntid unixid:ntid ..."
29 echo ""
30 echo "Example: smbadduser zak:zakharoffm johns:smithj"
31 echo $line
32 exit 1
33 endif
35 touch $smbpasswd $user_map
36 set new = ()
37 foreach one ($argv)
38 echo $one | grep ':' >& /dev/null
39 if ($status != 0) then
40 echo "ERROR: Must use unixid:ntid like -> zak:zakharoffm"
41 continue
42 endif
43 set unix = `echo $one | awk -F: '{print $1}'`
44 set ntid = `echo $one | awk -F: '{print $2}'`
46 set usr = `eval $passwd | awk -F: '$1==USR {print $1}' USR=$unix`
47 if ($#usr != 1) then
48 echo "ERROR: $unix Not in passwd database SKIPPING..."
49 continue
50 endif
51 set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix`
52 if ($#tmp != 0) then
53 echo "ERROR: $unix is already in $smbpasswd SKIPPING..."
54 continue
55 endif
57 echo "Adding: $unix to $smbpasswd"
58 /usr/bin/smbpasswd -a -n $unix
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