]> Git — Sourcephile - sourcephile-nix.git/blob - servers/mermet/openldap.nix
dovecot: no longer use auth_bind=no
[sourcephile-nix.git] / servers / mermet / openldap.nix
1 { pkgs, lib, config, ... }:
2 let inherit (builtins) baseNameOf readFile;
3 inherit (lib) types;
4 inherit (pkgs.lib) unlinesAttrs;
5 inherit (config) networking;
6 inherit (config.services) openldap;
7 inherit (config.users) ldap;
8 domainSuffix = "dc=" + lib.concatStringsSep ",dc=" (lib.splitString "." networking.domain);
9 in
10 {
11 imports = [
12 openldap/sourcephile.nix
13 ];
14 config = {
15 users.ldap = {
16 enable = true;
17 server = "ldapi:///";
18 base = "ou=posix,${domainSuffix}";
19 bind = {
20 #distinguishedName = "cn=admin,${domainSuffix}";
21 };
22 daemon = {
23 enable = true;
24 extraConfig = ''
25 log syslog debug
26
27 sasl_mech EXTERNAL
28 # NOTE: nslcd cannot use SASL to bind to rootpwmoddn
29 # which is the DN used by nslcd when passwd is run by root
30 # to change the userPassword of an LDAP user.
31 # SEE: https://www.reddit.com/r/linuxadmin/comments/53sxpl/how_do_i_configure_nslcd_to_use_a_sasl_external/d7w9awd/
32 # Thus, use: ldappasswd -H ldapi:// -Y EXTERNAL uid=$user,ou=accounts,ou=posix,dc=sourcephile,dc=fr
33 '';
34 };
35 };
36 services.openldap = {
37 enable = true;
38 dataDir = "/var/db/ldap";
39 configDir = "/var/db/slapd";
40 urlList = [ "ldapi:///" ]; # UNIX socket
41 };
42 };
43 }