Jail: ldap

one time
zfs create ship/ldap
mkdir /mnt/ship/ldap/openldap
mkdir /mnt/ship/ldap/openldap-data
chown -R 389:389 /mnt/ship/ldap/openldap-data

create jail
export JAIL=ldap
export JAILHOSTNAME=ldap
export JAILDOMAIN=ahlawat.com
export JAILIP=13
export JAILUSER=X
export JAILUSERID=1000
export JAILUSERVNC=false

/root/FreeBSD/jails/create.sh $JAIL $JAILHOSTNAME $JAILDOMAIN $JAILIP $JAILUSER $JAILUSERID $JAILUSERVNC

iocage fstab -a $JAIL /mnt/ship/ldap/openldap /usr/local/etc/openldap nullfs rw 0 0
iocage fstab -a $JAIL /mnt/ship/ldap/openldap-data /var/db/openldap-data nullfs rw 0 0
iocage fstab -l $JAIL

iocage exec $JAIL "pkg install -y openssl"

iocage exec $JAIL "pkg install -y -r pkgp121 openldap-sasl-server openldap-sasl-client"
iocage exec $JAIL "pkg lock -y openldap-sasl-server"
iocage exec $JAIL "pkg lock -y openldap-sasl-client"

iocage exec $JAIL "sysrc slapd_enable=YES"
iocage exec $JAIL "sysrc slapd_flags='-h "ldapi://%2Fvar%2Frun%2Fopenldap%2Fldapi/ ldap:/// ldaps:///"'"
# The above config entry needs to entered manually for now - too many quotes
iocage exec $JAIL "sysrc slapd_sockets=/var/run/openldap/ldapi"

iocage exec $JAIL "service slapd start"

Notes:
Debugging:
/usr/local/libexec/slapd -Tt
/usr/local/libexec/slapd -d1

ldapsearch -x -W -D cn=admin,dc=infra
ldapsearch -x -H ldap://ldap.ahlawat.com
ldapsearch -x -H ldaps://ldap.ahlawat.com

ldapsearch -h localhost -D cn=admin,dc=infra -b dc=infra -W
ldapsearch -h ldap.ahlawat.com -D cn=admin,dc=infra -b dc=infra -W



// First time
slappasswd -h '{SHA}'
nano /usr/local/etc/openldap/slapd.conf
#include all non wip schema
#Uncomment back_mdb and back_ldap
#add SHA password from previous command
rootpw          {SHA}...
logfile /var/log/slapd.log
loglevel 256
//



ldap openldap # diff slapd.conf slapd.conf.sample
5,16c5
< include   /usr/local/etc/openldap/schema/core.schema
< include /usr/local/etc/openldap/schema/cosine.schema
< include /usr/local/etc/openldap/schema/corba.schema
< include /usr/local/etc/openldap/schema/inetorgperson.schema
< include /usr/local/etc/openldap/schema/nis.schema
< include /usr/local/etc/openldap/schema/collective.schema
< include /usr/local/etc/openldap/schema/openldap.schema
< include /usr/local/etc/openldap/schema/duaconf.schema
< include /usr/local/etc/openldap/schema/dyngroup.schema
< include /usr/local/etc/openldap/schema/misc.schema
< include /usr/local/etc/openldap/schema/pmi.schema
< include /usr/local/etc/openldap/schema/ppolicy.schema
---
> include       /usr/local/etc/openldap/schema/core.schema
29,30c18,19
< moduleload    back_mdb
< moduleload    back_ldap
---
> # moduleload  back_mdb
> # moduleload  back_ldap
59,77d47
< #access to attrs=userPassword
< #    by self =wx
< #    by anonymous auth
< #    by users read
< #    by * none
<
< access to attrs=userPassword
<     by self write
<     by * read
<
< #access to *
< #    by self read
< #    by anonymous read
< #    by users read
< #    by * none
<
< access to *
<     by * read
<
84,86c54,55
< suffix        "dc=infra"
< rootdn        "cn=admin,dc=infra"
<
---
> suffix        "dc=my-domain,dc=com"
> rootdn        "cn=Manager,dc=my-domain,dc=com"
90,91c59
< rootpw        {SHA}...
<
---
> rootpw        secret
96d63
<
98,117c65
< index objectClass  eq
< index uid          eq
< index uidNumber    eq
< index uniqueMember eq
< index gidNumber    eq
< index cn           eq
< index memberUid    eq
< index mail         eq
<
< logfile /var/log/slapd.log
< loglevel 256
<
< overlay            memberof
< memberof-dangling  drop
< memberof-refint    TRUE
<
< TLSCertificateFile /mnt/certs/fullchain.pem
< TLSCertificateKeyFile /mnt/certs/privkeyr.pem
< TLSCACertificateFile /mnt/certs/fullchain.pem
< TLSDHParamFile /mnt/certs/dhparam4096.pem
---
> index objectClass eq
ldap openldap #


Showcased here is a capital and operational cost effective approach, using minimal server and networking hardware with multiple virtualized applications for Home and Business. This solution template can be easily scaled out and adapted for larger Enterprise deployments.
drop by the diyIT Matrix public room at #diyit:matrix.ahlawat.com
if you have any IT questions/feedback or to request pro bono consulting for a nonprofit

message me privately at @sharad:matrix.ahlawat.com
or email me at - sharad@ahlawat.com - pgpkey: 68DD6B89
Networking and Security Technologist.
EngineerĀ andĀ an avid Programmer.

https://sharad.ahlawat.com
strive to learn and pass on the knowledge to the next generation
one day humanity will understand the meaning of life and hopefully it will be more than ASCII 42 = "*" regex for whatever you want it to be,
and destiny is more than just a roll of a pair of dice with 42 dots (Lets nail down Quantum Entanglement)

May you Live Long (Intelligently) and Prosper and work on technology that matters.
© 2024 Sharad Ahlawat

No personal identifying data is collected or any form of analytics/metrics reported to a third-party by this website.