# Purge any existing OpenLDAP instances or images docker rm -f kpldap docker rmi -f bitnami/openldap # Instantiating the OpenLDAP service using the OpenLDAP docker image docker run --detach --hostname kpdocker --name kpldap --network bridge\ --env LDAP_ROOT=dc=knifeparty,dc=local \ --env LDAP_ADMIN_USERNAME=kpadmin \ --env LDAP_ADMIN_PASSWORD=P@55word! \ --env LDAP_ADMIN_DN=cn=kpadmin,ou=users,dc=knifeparty,dc=local \ --env LDAP_ALLOW_ANON_BINDING=yes\ --env LDAP_USER_DC=users\ --env LDAP_GROUP_DC=groups\ -v openldap5:/bitnami/openldap\ -p 1389:1389 \ bitnami/openldap:latest # Downloading the required LDIF files for configuring the OpenLDAP docker instance # The LDIF file assists in creating an OU, a group, few users and adding the users to the group wget https://raw.githubusercontent.com/pdoffl/LRAD/refs/heads/main/ldap_cfgfile_01.ldif -O ldap_cfgfile_01.ldif wget https://raw.githubusercontent.com/pdoffl/LRAD/refs/heads/main/ldap_cfgfile_02.ldif -O ldap_cfgfile_02.ldif # Copying the LDIF file in the docker instance docker cp ldap_cfgfile_01.ldif kpldap:/root/ldap_cfgfile_01.ldif docker cp ldap_cfgfile_02.ldif kpldap:/root/ldap_cfgfile_02.ldif # Wait for 4 seconds sleep 4 # Executing 'ldapadd' command inside docker instance to add changes to the LDAP service as specified in the LDIF files docker exec -u root -it kpldap sh -c "ldapadd -x -H ldap://127.0.0.1:1389 -D 'cn=kpadmin,dc=knifeparty,dc=local' -w P@55word! -f /root/ldap_cfgfile_01.ldif; ldapadd -x -H ldap://127.0.0.1:1389 -D 'cn=kpadmin,dc=knifeparty,dc=local' -w P@55word! -f /root/ldap_cfgfile_02.ldif"