source $GRIMOIRE/config_query_multi.function &&

config_query_option OPENLDAP_SLAPD 'Build SLAPD, the standalone LDAP daemon?' y \
  '--enable-slapd --enable-modules' '--disable-slapd' &&

if echo $OPENLDAP_SLAPD | grep -q enable; then
  config_query_option SLAPD_DNSSRV 'Enable DNS backend? (LDAP server locator)' n \
                      '--enable-dnssrv=mod' '--disable-dnssrv' &&
  config_query_option SLAPD_META 'Enable metadirectory backend?' n \
                      '--enable-meta=mod' '--disable-meta' &&
  config_query_option SLAPD_MONITOR 'Enable LDAP server monitor backend?' y \
                      '--enable-monitor=mod' '--disable-monitor' &&
  config_query_option SLAPD_SOCK 'Enable sock backend?' n \
                      '--enable-sock=mod' '--disable-sock' &&
  config_query_option SLAPD_RELAY 'Enable relay backend?' n \
                      '--enable-relay=mod' '--disable-relay' &&
  config_query_option SLAPD_ACL 'Enable EXPERIMENTAL loadable ACL?' n \
                      '--enable-dynacl' '--disable-dynacl' &&
  if echo $SLAPD_ACL|grep -q enable; then
    config_query_option SLAPD_ACI 'Enable per-object access control' n \
                      '--enable-aci' '--disable-aci'
  fi &&
  config_query_option SLAPD_CLEAR 'Enable cleartext passwords?' y \
                      '--enable-cleartext' '--disable-cleartext' &&
  config_query_option SLAPD_CRYPT 'Enable crypt passwords?' n \
                      '--enable-crypt' '--disable-crypt' &&
  config_query_option SLAPD_REV 'Enable reverse lookup of client hostnames?' n \
                      '--enable-rlookups' '--disable-rlookups'
fi &&

config_query OPENLDAP_NTLM "Enable NTLM API support (needed for Evolution Exchange plugin)?" n &&

config_query_multi SLAPD_OVERLAYS \
                   "which overlays do you want supported?" \
                   none all \
                   accesslog auditlog collect constraint dds deref dyngroup \
                   dynlist memberof ppolicy proxycache refint retcode rwm \
                   seqmod sssvlv syncprov translucent unique valsort

if list_find "$SLAPD_OVERLAYS" "all"; then
  SLAPD_OVERLAYS="all"
elif list_find "$SLAPD_OVERLAYS" "none"; then
  SLAPD_OVERLAYS="none"
fi &&

if echo $OPENLDAP_SLURPD |grep -q enable ; then
  if list_find "$SLAPD_OVERLAYS" "syncprov"; then
    message 'slurpd has been replaced by the syncprov overlay'
  else
    message 'slurpd has been replaced by the syncprov overlay, adding it' &&
    SLAPD_OVERLAYS="${SLAPD_OVERLAYS} syncprov"
  fi &&
  persistent_remove OPENLDAP_SLURPD
fi &&

message "${MESSAGE_COLOR}If you care about security, check out http://timof.qipc.org/ldap/libldap.html .$DEFAULT_COLOR" &&
message "${MESSAGE_COLOR}The patch is not in the spell anymore because of version mismatch...$DEFAULT_COLOR."
