aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-09 22:43:24 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-09 22:43:24 +0100
commite51bff05d225ce68143b0aefa282116fe5eb587f (patch)
treeb09a71d7b6ec7ecd0b223770a40bfbf3defe6d6c
parentdb9840a6f1d708ca3c333761fd051f328c2bd9f3 (diff)
downloadguichet-e51bff05d225ce68143b0aefa282116fe5eb587f.tar.gz
guichet-e51bff05d225ce68143b0aefa282116fe5eb587f.zip
Also show groups/members when none are present for some object classes
-rw-r--r--admin.go45
-rw-r--r--templates/admin_ldap.html6
2 files changed, 39 insertions, 12 deletions
diff --git a/admin.go b/admin.go
index 70d555f..def23d6 100644
--- a/admin.go
+++ b/admin.go
@@ -123,11 +123,15 @@ func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
type AdminLDAPTplData struct {
DN string
+
+ Path []PathItem
+ Children []Child
+ Props map[string]*PropValues
+
+ HasMembers bool
Members []EntryName
+ HasGroups bool
Groups []EntryName
- Props map[string]*PropValues
- Children []Child
- Path []PathItem
Error string
Success bool
@@ -151,6 +155,7 @@ type PathItem struct {
}
type PropValues struct {
+ Name string
Values []string
Editable bool
}
@@ -306,8 +311,9 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
props := make(map[string]*PropValues)
for _, attr := range object.Attributes {
- if attr.Name != dn_last_attr {
- if existing, ok := props[attr.Name]; ok {
+ name_lower := strings.ToLower(attr.Name)
+ if name_lower != dn_last_attr {
+ if existing, ok := props[name_lower]; ok {
existing.Values = append(existing.Values, attr.Values...)
} else {
editable := true
@@ -320,7 +326,8 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
break
}
}
- props[attr.Name] = &PropValues{
+ props[name_lower] = &PropValues{
+ Name: attr.Name,
Values: attr.Values,
Editable: editable,
}
@@ -415,13 +422,33 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
})
}
+ // Checkup objectclass
+ objectClass := []string{}
+ if val, ok := props["objectclass"]; ok {
+ objectClass = val.Values
+ }
+ hasMembers, hasGroups := false, false
+ for _, oc := range objectClass {
+ if strings.EqualFold(oc, "organizationalperson") || strings.EqualFold(oc, "person") {
+ hasGroups = true
+ }
+ if strings.EqualFold(oc, "groupOfNames") {
+ hasMembers = true
+ }
+ }
+
templateAdminLDAP.Execute(w, &AdminLDAPTplData{
DN: dn,
+
+ Path: path,
+ Children: children,
+ Props: props,
+
+ HasMembers: len(members) > 0 || hasMembers,
Members: members,
+ HasGroups: len(groups) > 0 || hasGroups,
Groups: groups,
- Props: props,
- Children: children,
- Path: path,
+
Error: dError,
Success: dSuccess,
})
diff --git a/templates/admin_ldap.html b/templates/admin_ldap.html
index b72f587..fa4b934 100644
--- a/templates/admin_ldap.html
+++ b/templates/admin_ldap.html
@@ -51,7 +51,7 @@
{{range $key, $value := .Props}}
{{if $value.Editable}}
<div class="row mt-4">
- <div class="col-md-3"><strong>{{$key}}</strong></div>
+ <div class="col-md-3"><strong>{{$value.Name}}</strong></div>
<div class="col-md-7">
<form method="POST">
@@ -106,7 +106,7 @@
</form>
</div>
-{{if .Members}}
+{{if .HasMembers}}
<hr class="mt-4" />
<h5 class="mt-4">Membres</h5>
<div class="container">
@@ -143,7 +143,7 @@
</div>
{{end}}
-{{if .Groups}}
+{{if .HasGroups}}
<hr class="mt-4" />
<h5 class="mt-4">Membre de</h5>
<div class="container">