ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSAdmin/adduser.sh
Revision: 563
Committed: 2005-08-28T01:55:06-07:00 (19 years, 9 months ago) by douglas
Content type: text/x-sh
File size: 1485 byte(s)
Log Message:
Whee!

File Contents

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

Properties

Name Value
svn:executable *