1 |
#!/usr/local/bin/bash |
2 |
# Douglas Thrift |
3 |
# |
4 |
# CCS Computer Science |
5 |
# |
6 |
# Add User |
7 |
|
8 |
source '/ccs/bin/common.sh' |
9 |
|
10 |
BASE='dc=ccs,dc=ucsb,dc=edu' |
11 |
SECRET='/ccs/etc/secret' |
12 |
|
13 |
ID=$((`$ldapsearch -b "ou=People,$BASE" -LLL -S 'uidNumber' 'uidNumber' \ |
14 |
| $sed -Ee 's/^uidNumber: (1[0-9]{3})$/\1/p;d' | $tail -n 1` + 1)) |
15 |
|
16 |
$ldapadd -D "uid=root,ou=People,$BASE" -x -y $SECRET <<EOF |
17 |
dn: uid=$USER,ou=People,$BASE |
18 |
objectclass: top |
19 |
objectclass: account |
20 |
objectclass: posixAccount |
21 |
objectclass: ucsbCcsLoginShells |
22 |
objectclass: sambaSamAccount |
23 |
cn: $NAME |
24 |
uid: $USER |
25 |
uidNumber: $ID |
26 |
gidNumber: $ID |
27 |
homeDirectory: /home/$USER |
28 |
userPassword: `$slappasswd -T $FILE` |
29 |
ucsbCcsFreebsd: /usr/local/bin/bash |
30 |
ucsbCcsLinux: /bin/bash |
31 |
ucsbCcsDarwin: /bin/bash |
32 |
sambaPwdLastSet: `$date '+%s'` |
33 |
sambaAcctFlags: [U ] |
34 |
sambaSID: S-1-5-21-3739982181-3886045993-82308153-$ID |
35 |
sambaPrimaryGroupSID: S-1-5-21-3739982181-3886045993-82308153-$((ID + 1000)) |
36 |
|
37 |
dn: cn=$USER,ou=Group,$BASE |
38 |
objectclass: top |
39 |
objectclass: posixGroup |
40 |
objectclass: sambaGroupMapping |
41 |
cn: $USER |
42 |
gidNumber: $ID |
43 |
sambaSID: S-1-5-21-3739982181-3886045993-82308153-$((ID + 1000)) |
44 |
sambaGroupType: 4 |
45 |
EOF |
46 |
|
47 |
$ldapmodify -D "uid=root,ou=People,$BASE" -x -y $SECRET <<<"`$ldapsearch -b \ |
48 |
"ou=Group,$BASE" -LLL 'cn=wheel' | $sed -e "s/^$/memberUid: $USER/"`" |
49 |
|
50 |
$smbpasswd -s $USER |