Also show groups/members when none are present for some object classes
This commit is contained in:
parent
db9840a6f1
commit
e51bff05d2
2 changed files with 41 additions and 14 deletions
49
admin.go
49
admin.go
|
@ -123,11 +123,15 @@ func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
type AdminLDAPTplData struct {
|
type AdminLDAPTplData struct {
|
||||||
DN string
|
DN string
|
||||||
Members []EntryName
|
|
||||||
Groups []EntryName
|
|
||||||
Props map[string]*PropValues
|
|
||||||
Children []Child
|
|
||||||
Path []PathItem
|
Path []PathItem
|
||||||
|
Children []Child
|
||||||
|
Props map[string]*PropValues
|
||||||
|
|
||||||
|
HasMembers bool
|
||||||
|
Members []EntryName
|
||||||
|
HasGroups bool
|
||||||
|
Groups []EntryName
|
||||||
|
|
||||||
Error string
|
Error string
|
||||||
Success bool
|
Success bool
|
||||||
|
@ -151,6 +155,7 @@ type PathItem struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PropValues struct {
|
type PropValues struct {
|
||||||
|
Name string
|
||||||
Values []string
|
Values []string
|
||||||
Editable bool
|
Editable bool
|
||||||
}
|
}
|
||||||
|
@ -306,8 +311,9 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
props := make(map[string]*PropValues)
|
props := make(map[string]*PropValues)
|
||||||
for _, attr := range object.Attributes {
|
for _, attr := range object.Attributes {
|
||||||
if attr.Name != dn_last_attr {
|
name_lower := strings.ToLower(attr.Name)
|
||||||
if existing, ok := props[attr.Name]; ok {
|
if name_lower != dn_last_attr {
|
||||||
|
if existing, ok := props[name_lower]; ok {
|
||||||
existing.Values = append(existing.Values, attr.Values...)
|
existing.Values = append(existing.Values, attr.Values...)
|
||||||
} else {
|
} else {
|
||||||
editable := true
|
editable := true
|
||||||
|
@ -320,7 +326,8 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
props[attr.Name] = &PropValues{
|
props[name_lower] = &PropValues{
|
||||||
|
Name: attr.Name,
|
||||||
Values: attr.Values,
|
Values: attr.Values,
|
||||||
Editable: editable,
|
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{
|
templateAdminLDAP.Execute(w, &AdminLDAPTplData{
|
||||||
DN: dn,
|
DN: dn,
|
||||||
Members: members,
|
|
||||||
Groups: groups,
|
|
||||||
Props: props,
|
|
||||||
Children: children,
|
|
||||||
Path: path,
|
Path: path,
|
||||||
|
Children: children,
|
||||||
|
Props: props,
|
||||||
|
|
||||||
|
HasMembers: len(members) > 0 || hasMembers,
|
||||||
|
Members: members,
|
||||||
|
HasGroups: len(groups) > 0 || hasGroups,
|
||||||
|
Groups: groups,
|
||||||
|
|
||||||
Error: dError,
|
Error: dError,
|
||||||
Success: dSuccess,
|
Success: dSuccess,
|
||||||
})
|
})
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
{{range $key, $value := .Props}}
|
{{range $key, $value := .Props}}
|
||||||
{{if $value.Editable}}
|
{{if $value.Editable}}
|
||||||
<div class="row mt-4">
|
<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">
|
<div class="col-md-7">
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{if .Members}}
|
{{if .HasMembers}}
|
||||||
<hr class="mt-4" />
|
<hr class="mt-4" />
|
||||||
<h5 class="mt-4">Membres</h5>
|
<h5 class="mt-4">Membres</h5>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -143,7 +143,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if .Groups}}
|
{{if .HasGroups}}
|
||||||
<hr class="mt-4" />
|
<hr class="mt-4" />
|
||||||
<h5 class="mt-4">Membre de</h5>
|
<h5 class="mt-4">Membre de</h5>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
Loading…
Reference in a new issue