1 { pkgs, lib, config, ... }:
3 inherit (builtins) baseNameOf readFile;
5 inherit (pkgs.lib) unlinesAttrs;
6 inherit (config) networking;
7 inherit (config.services) openldap;
8 inherit (config.users) ldap;
9 domainSuffix = "dc=" + lib.concatStringsSep ",dc=" (lib.splitString "." networking.domain);
13 openldap/sourcephile.fr.nix
19 base = "ou=posix,${domainSuffix}";
21 #distinguishedName = "cn=admin,${domainSuffix}";
29 # NOTE: nslcd cannot use SASL to bind to rootpwmoddn
30 # which is the DN used by nslcd when passwd is run by root
31 # to change the userPassword of an LDAP user.
32 # SEE: https://www.reddit.com/r/linuxadmin/comments/53sxpl/how_do_i_configure_nslcd_to_use_a_sasl_external/d7w9awd/
33 # Thus, use: ldappasswd -H ldapi:// -Y EXTERNAL uid=$user,ou=accounts,ou=posix,dc=sourcephile,dc=fr
39 dataDir = "/var/db/ldap";
40 configDir = "/var/db/slapd";
41 urlList = [ "ldapi:///" ]; # UNIX socket
42 # sudo ldapsearch -LLL -H ldapi:// -D cn=admin,cn=config -Y EXTERNAL -b "" -s base supportedControl
45 objectClass: olcGlobal
47 # The tool-threads parameter sets the actual amount of CPU's
48 # that is used for indexing.
49 olcToolThreads: ${toString config.nix.maxJobs}
51 dn: cn={0}module,cn=config
52 objectClass: olcModuleList
53 olcModulePath: ${pkgs.openldap}/lib/modules
54 olcModuleLoad: pw-sha2
55 olcModuleLoad: pw-pbkdf2
56 olcModuleLoad: back_mdb
58 # The first database is the special frontend database
59 # whose settings are applied globally to all the other databases.
60 # Beware that cn={0}module,cn=config must appear before
61 # for enabling password schemes provided by the modules in olcPasswordHash.
62 # ldapsearch -LLL -H ldapi:// -D cn=admin,cn=config -Y EXTERNAL -b 'olcDatabase={-1}frontend,cn=config' -s sub '*'
63 dn: olcDatabase={-1}frontend,cn=config
64 objectClass: olcDatabaseConfig
65 objectClass: olcFrontendConfig
66 # The maximum number of entries that is returned for a search operation
68 # Allow unlimited access to local connection from the local root user
70 by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth manage
72 # Allow unauthenticated read access for schema and base DN autodiscovery
73 olcAccess: to dn.exact=""
75 olcAccess: to dn.base="cn=Subschema"
77 # Hash algorithm to be used by LDAP Password Modify Extended Operation or the ppolicy overlay
78 olcPasswordHash: {PBKDF2-SHA256}
80 dn: olcDatabase={0}config,cn=config
81 objectClass: olcDatabaseConfig
82 olcRootDN: cn=admin,cn=config
83 # Access to cn=config, system root can be manager
84 # with SASL mechanism (-Y EXTERNAL) over unix socket (-H ldapi://)
86 by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage
89 dn: cn=schema,cn=config
90 objectClass: olcSchemaConfig
92 include: file://${pkgs.openldap}/etc/schema/core.ldif
93 include: file://${pkgs.openldap}/etc/schema/cosine.ldif
94 include: file://${pkgs.openldap}/etc/schema/nis.ldif
95 include: file://${pkgs.openldap}/etc/schema/inetorgperson.ldif
96 include: file://${openldap/schema/postfix-book.ldif}