From 61a76f624decd9d9ef3afadaf584d46fe56e0817 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 10 Feb 2020 09:54:33 +0100 Subject: [PATCH] Make some values non deletable --- admin.go | 9 +++++++++ templates/admin_ldap.html | 12 +++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/admin.go b/admin.go index 870439f..7806cfd 100644 --- a/admin.go +++ b/admin.go @@ -164,6 +164,7 @@ type PropValues struct { Name string Values []string Editable bool + Deletable bool } func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { @@ -342,10 +343,18 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { break } } + deletable := true + for _, restricted := range []string{ "displayname", "objectclass", "structuralobjectclass" } { + if strings.EqualFold(attr.Name, restricted) { + deletable = false + break + } + } props[name_lower] = &PropValues{ Name: attr.Name, Values: attr.Values, Editable: editable, + Deletable: deletable, } } } diff --git a/templates/admin_ldap.html b/templates/admin_ldap.html index 4480d10..c7a0872 100644 --- a/templates/admin_ldap.html +++ b/templates/admin_ldap.html @@ -76,11 +76,13 @@
-
- - - -
+ {{if $value.Deletable}} +
+ + + +
+ {{end}}
{{end}}