Skip to content

Instantly share code, notes, and snippets.

@hacker65536
Last active May 30, 2016 12:52
Show Gist options
  • Save hacker65536/d7a1014ff64c638315366d31148a5669 to your computer and use it in GitHub Desktop.
Save hacker65536/d7a1014ff64c638315366d31148a5669 to your computer and use it in GitHub Desktop.
#!/bin/bash
# set ERR trap
set -e
# generate password SSHA
PASS=$(slappasswd -s password)
PASS1=${PASS}
FILE='ldapconf_init_passwd.ldif'
SUFFFIX="dc=testcompany,dc=com"
#exec 5> ${FILE}
#discriptor
cat <<EOF | ldapmodify -Y EXTERNAL -H ldapi:///
dn: olcDatabase={0}config,cn=config
changeType: modify
add: olcRootPW
olcRootPW: ${PASS}
EOF
cat <<EOF | ldapmodify -Y EXTERNAL -H ldapi:///
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
read by dn.base="cn=Manager,${SUFFFIX}" read by * none
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: ${SUFFFIX}
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,${SUFFFIX}
dn: olcDatabase={2}bdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: ${PASS1}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment