- 论坛徽章:
- 2
|
10可用积分
本帖最后由 now163 于 2014-07-29 22:17 编辑
目前有一个批量添加ldap账户的需求,分别有user.txt,passwd.txt
cat -n user.txt
1 test01
2 test01
cat -n passwd.txt
1 {crypt}$1$$CEfu80ee2k3Kd2B1su.bv1
2 {crypt}$1$eGSiENMg$bsszlc.65SJ6uOomQQCLv1
账户密码要一一对应。
下面是原脚本里面的一段,小白不会修改 - add_new_user()
- {
- USERNAME="$(echo $1 | tr [A-Z] [a-z])"
- MAIL="$( echo $2 | tr [A-Z] [a-z])"
- # Create template LDIF file for this new user and add it.
- # If you do *NOT* want to keep rootpw in script, use '-W' instead of
- # '-w "${BINDPW}".
- maildir="$( hash_domain ${DOMAIN_NAME})/$( hash_maildir ${USERNAME} )"
- # Generate user password.
- if [ X"${USE_DEFAULT_PASSWD}" == X"YES" ]; then
- PASSWD="$(slappasswd -h {${CRYPT_MECH}} -s ${DEFAULT_PASSWD})"
- else
- PASSWD="$(slappasswd -h {${CRYPT_MECH}} -s ${USERNAME})"
- fi
- ldapadd -x -D "${BINDDN}" -w "${BINDPW}" <<EOF
- dn: mail=${MAIL},${OU_USER_DN},${DOMAIN_DN},${BASE_DN}
- objectClass: inetOrgPerson
- objectClass: shadowAccount
- objectClass: amavisAccount
- objectClass: mailUser
- objectClass: top
- accountStatus: active
- storageBaseDirectory: ${STORAGE_BASE}
- homeDirectory: ${STORAGE_BASE_DIRECTORY}/${maildir}
- mailMessageStore: ${STORAGE_NODE}/${maildir}
- mail: ${MAIL}
- mailQuota: ${QUOTA}
- userPassword:[b] ${PASSWD}[/b]
- cn: ${USERNAME}
- sn: ${USERNAME}
- givenName: [b]${USERNAME}[/b]
- uid: ${USERNAME}
- shadowLastChange: 0
- amavisLocal: TRUE
- enabledService: internal
- enabledService: doveadm
- enabledService: lib-storage
- enabledService: mail
- enabledService: pop3
- enabledService: pop3secured
- enabledService: imap
- enabledService: imapsecured
- enabledService: managesieve
- enabledService: managesievesecured
- enabledService: sieve
- enabledService: sievesecured
- enabledService: smtp
- enabledService: smtpsecured
- enabledService: deliver
- enabledService: lda
- enabledService: lmtp
- enabledService: forward
- enabledService: senderbcc
- enabledService: recipientbcc
- enabledService: shadowaddress
- enabledService: displayedInGlobalAddressBook
- ${LDIF_PUREFTPD_USER}
- EOF
- }
复制代码 里面的$1是域名:abc.com $2是user 脚本添加的时候可以用./add.sh abc.com $(cat user.txt)
默认是用slappasswd生成一个和用户名相同的密码,怎样才能改成我的需求呢?
请各位帮帮忙,免去我手动修改几百个的账户信息 |
|