## 須先確認 uid Number 爾後創的檔案需放置於此shell script同目錄下。
## 僅提供輸入 帳戶、密碼、姓、名、uidNumber (會顯示最後的uidNumber作為參考)。
#!/bin/sh
echo -n "Please input UserName : "
read user
passwd=`slappasswd -crypt`
echo -n "Please input First Name : "
read first
echo -n "Please input Last Name : "
read last
lst=`ls -t | head -1` --->列出最後修改的一個檔案
echo $lst
leuid=`grep uidNumber < $lst` --->擷取 uidNumber資訊
echo $leuid
echo -n "Please input UID : "
read uidnumber
touch user.$user.ldif
F=user.$user.ldif
echo dn: uid=$user,ou=user,dc=rich,dc=com >> $F
echo uid: $user >> $F
echo cn: $user >> $F
echo objectClass: account >> $F
echo objectClass: posixAccount >>$F
echo objectClass: shadowAccount >>$F
echo userPassword: $passwd >>$F
echo shadowLastChange: 14089 >>$F
echo shadowMax: 99999 >>$F
echo shadowWarning: 7 >>$F
echo loginShell: /bin/bash >>$F
echo uidNumber: $uidnumber >>$F
echo gidNumber: 201 >>$F
echo homeDirectory: /home/$user >>$F
echo gecos: $first $last >>$F
service ldap stop
sleep 2
slapadd -v -l $F
sleep 2
service ldap start
exit 0
標籤
- 上課實作 (7)
- 高級實作 (3)
- 雜貨店 (6)
- Exchange Server (3)
- grub組態設定 (1)
- IIS架站 (1)
- Juniper_SSG (4)
- L2 switch (2)
- L3 switch (4)
- Server2003 (6)
- Server2008 (5)
- Shell Script Programming (3)
- TCP/IP (1)
- Wirless_Aruba (4)
沒有留言:
張貼留言