Exercise 4: build an LDAP server ================================ This is by far the hardest part of the operation, due to the cryptic way OpenLDAP 2.4 now stores its configs within LDAP instead of in a config file. See `man slapd-config` We are going to build an LDAP server with Base DN "dc=realm1,dc=ws,dc=nsrc,dc=org". Change this to match your own realm. Install the slapd server and ensure everything else needed is present: # apt-get install slapd ldap-utils libsasl2-modules-gssapi-mit Set up the service principal with keytab readable by slapd: # mkdir /etc/ldap/krb5 # kadmin -p student/admin addprinc -randkey ldap/pc1.ws.nsrc.org ktadd -k /etc/ldap/krb5/krb5.keytab ldap/pc1.ws.nsrc.org ^D # chown -R openldap:openldap /etc/ldap/krb5 # chmod 550 /etc/ldap/krb5 # chmod 440 /etc/ldap/krb5/krb5.keytab # editor /etc/default/slapd ... export KRB5_KTNAME=/etc/ldap/krb5/krb5.keytab # service slapd restart Install the schemas we need: # ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif # ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif # ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif # ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/misc.ldif NOTE: For a real production LDAP server, read the files in `/usr/share/doc/slapd` carefully, especially README.Debian.gz and README.DB_CONFIG.gz Now we need to run some scripts - either paste directly to a root shell, or create in temporary files and then run them. BEWARE: in LDIF files, superfluous spaces at the end of lines may cause attributes to be rejected as invalid! First is `create_database.sh` ldapadd -Y EXTERNAL -H ldapi:/// <' will make an LDAP query as the current user. Make sure that the current user has a kerberos ticket. ldapscripts ----------- There is a package called `ldapscripts` with simple tools for adding and managing LDAP users. Unfortunately it doesn't know about GSSAPI authentication, so you need to patch it. See ldapscripts-sasl.diff Then configure it: # editor /etc/ldapscripts/ldapscripts.conf SASLAUTH="GSSAPI" ... SERVER="ldap://pc1.ws.nsrc.org" ... SUFFIX="dc=realm1,dc=ws,dc=nsrc,dc=org" Then adding a new user in LDAP is as simple as: $ kinit student/admin $ ldapadduser someuser users $ kdestroy Adding groups and users into groups: $ ldapaddgroup noc $ ldapaddusertogroup someuser noc You may need to restart nscd before 'id' shows this information. Configure backup LDAP --------------------- OpenLDAP replication is left as an exercise to the reader.