cat > memberof_conf.ldif<
cat > refint1.ldif <
cat > refint2.ldif << EOF
dn: olcOverlay=refint,olcDatabase={2}hdb,cn=config
objectClass: olcConfig
objectClass: olcOverlayConfig
objectClass: olcRefintConfig
objectClass: top
olcOverlay: refint
olcRefintAttribute: memberof uniqueMember manager owner
EOF
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f memberof_conf.ldif
ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f refint1.ldif
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f refint2.ldif
ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn | grep olcOverlay
dn: olcOverlay={0}memberof,olcDatabase={2}hdb,cn=config
dn: olcOverlay={1}refint,olcDatabase={2}hdb,cn=config
以上步骤就完成了OpenLDAP的MemberOf模块启用
cat > organizationalUnit.ldif << EOF
dn: ou=host,dc=neoclub,dc=cn
ou: People
objectClass: organizationalUnit
objectClass: top
dn: ou=Group,dc=neoclub,dc=cn
ou: People
objectClass: organizationalUnit
objectClass: top
EOF
cat > test_user.ldif >> EOF
dn: uid=test,ou=People,dc=neoclub,dc=cn
uid: test
cn: test
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: 123456
shadowLastChange: 17694
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 10001
gidNumber: 10001
homeDirectory: /home/users/test
EOF
cat > test_group.ldif<
ldapadd -D "cn=admin,dc=neoclub,dc=cn" -W -x -f organizationalUnit.ldif .ldif
ldapadd -D "cn=admin,dc=neoclub,dc=cn" -W -x -f test_user.ldif
ldapadd -D "cn=admin,dc=neoclub,dc=cn" -W -x -f test_group.ldif
ldapsearch -LL -Y EXTERNAL -H ldapi:/// "(uid=test)" -b dc=neoclub,dc=cn memberOf
dn: cn=test,ou=People,dc=shigen,dc=com
memberOf: cn=test_admin,ou=Group,dc=neoclub,dc=cn