diff options
-rw-r--r-- | admin.go | 9 | ||||
-rw-r--r-- | templates/admin_ldap.html | 12 |
2 files changed, 16 insertions, 5 deletions
@@ -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 @@ </div> <div class="col-md-1"> - <form method="POST" onsubmit="return confirm('Supprimer cet attribut ?');"> - <input type="hidden" name="action" value="delete" /> - <input type="hidden" name="attr" value="{{$key}}" /> - <input type="submit" value="Suppr." class="form-control btn btn-danger btn-sm" /> - </form> + {{if $value.Deletable}} + <form method="POST" onsubmit="return confirm('Supprimer cet attribut ?');"> + <input type="hidden" name="action" value="delete" /> + <input type="hidden" name="attr" value="{{$key}}" /> + <input type="submit" value="Suppr." class="form-control btn btn-danger btn-sm" /> + </form> + {{end}} </div> </div> {{end}} |