]> git.proxmox.com Git - pmg-api.git/blobdiff - PMG/LDAPConfig.pm
reload postfix instead of restart on config change
[pmg-api.git] / PMG / LDAPConfig.pm
index 5f3c451b86f6dbb99440d6ba9ac5744e064aafe3..9e4fd9e7e4a90083843f384644604eb0b8098fdf 100644 (file)
@@ -12,6 +12,19 @@ use PVE::SectionConfig;
 
 use base qw(PVE::SectionConfig);
 
+PVE::JSONSchema::register_format('ldap-simple-attr', \&verify_ldap_simple_attr);
+sub verify_ldap_simple_attr {
+    my ($attr, $noerr) = @_;
+
+    if ($attr =~ m/^[a-zA-Z0-9]+$/) {
+       return $attr;
+    }
+
+    die "value '$attr' does not look like a simple ldap attribute name\n" if !$noerr;
+
+    return undef;
+}
+
 my $inotify_file_id = 'pmg-ldap.conf';
 my $config_filename = '/etc/pmg/ldap.conf';
 
@@ -25,6 +38,7 @@ my $defaultData = {
     },
 };
 
+
 sub properties {
     return {
        disable => {
@@ -39,11 +53,22 @@ sub properties {
            maxLength => 4096,
        },
        mode => {
-           description => "LDAP protocol mode ('ldap' or 'ldaps').",
+           description => "LDAP protocol mode ('ldap', 'ldaps' or 'ldap+starttls').",
            type => 'string',
-           enum => ['ldap', 'ldaps'],
+           enum => ['ldap', 'ldaps', 'ldap+starttls'],
            default => 'ldap',
        },
+       verify => {
+           description => "Verify server certificate. Only useful with ldaps or ldap+starttls.",
+           type => 'boolean',
+           default => 0,
+           optional => 1,
+       },
+       cafile => {
+           description => "Path to CA file. Only useful with option 'verify'",
+           type => 'string',
+           optional => 1,
+       },
        server1 => {
            description => "Server address.",
            type => 'string', format => 'address',
@@ -82,19 +107,17 @@ sub properties {
        },
        accountattr => {
            description => "Account attribute name name.",
-           type => 'string', format => 'string-list',
-           pattern => '[a-zA-Z0-9]+',
+           type => 'string', format => 'ldap-simple-attr-list',
            default => 'sAMAccountName, uid',
        },
        mailattr => {
            description => "List of mail attribute names.",
-           type => 'string', format => 'string-list',
-           pattern => '[a-zA-Z0-9]+',
-           default => "mail, userPrincipalName, proxyAddresses, othermailbox",
+           type => 'string', format => 'ldap-simple-attr-list',
+           default => "mail, userPrincipalName, proxyAddresses, othermailbox, mailAlternativeAddress",
        },
        groupclass => {
            description => "List of objectclasses for groups.",
-           type => 'string', format => 'string-list',
+           type => 'string', format => 'ldap-simple-attr-list',
            default => "group, univentionGroup, ipausergroup",
        },
     };
@@ -116,6 +139,8 @@ sub options {
        accountattr => { optional => 1 },
        mailattr => { optional => 1 },
        groupclass => { optional => 1 },
+       verify => { optional => 1 },
+       cafile => { optional => 1 },
     };
 }