aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin.go25
-rw-r--r--templates/admin_create.html13
-rw-r--r--templates/admin_ldap.html19
3 files changed, 49 insertions, 8 deletions
diff --git a/admin.go b/admin.go
index a786a1e..a28c266 100644
--- a/admin.go
+++ b/admin.go
@@ -126,6 +126,7 @@ type AdminLDAPTplData struct {
Path []PathItem
Children []Child
+ CanAddChild bool
Props map[string]*PropValues
HasMembers bool
@@ -443,6 +444,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
Path: path,
Children: children,
Props: props,
+ CanAddChild: dn_last_attr == "ou",
HasMembers: len(members) > 0 || hasMembers,
Members: members,
@@ -456,6 +458,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
type CreateData struct {
SuperDN string
+ Path []PathItem
IdType string
IdValue string
@@ -477,8 +480,27 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
template := mux.Vars(r)["template"]
super_dn := mux.Vars(r)["super_dn"]
+ // Build path
+ path := []PathItem{
+ PathItem{
+ DN: config.BaseDN,
+ Identifier: config.BaseDN,
+ },
+ }
+
+ len_base_dn := len(strings.Split(config.BaseDN, ","))
+ dn_split := strings.Split(super_dn, ",")
+ for i := len_base_dn + 1; i <= len(dn_split); i++ {
+ path = append(path, PathItem{
+ DN: strings.Join(dn_split[len(dn_split)-i:len(dn_split)], ","),
+ Identifier: dn_split[len(dn_split)-i],
+ })
+ }
+
+ // Handle data
data := &CreateData{
SuperDN: super_dn,
+ Path: path,
}
if template == "user" {
data.IdType = config.UserNameAttr
@@ -488,6 +510,9 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
data.IdType = config.UserNameAttr
data.StructuralObjectClass = "groupOfNames"
data.ObjectClass = "groupOfNames\ntop"
+ } else {
+ data.IdType = "cn"
+ data.ObjectClass = "top"
}
if r.Method == "POST" {
diff --git a/templates/admin_create.html b/templates/admin_create.html
index 94dee5b..3e636a5 100644
--- a/templates/admin_create.html
+++ b/templates/admin_create.html
@@ -6,6 +6,17 @@
<a class="ml-auto btn btn-info" href="/">Retour</a>
</div>
+<div class="mt-4">
+ <nav aria-label="breadcrumb">
+ <ol class="breadcrumb">
+ {{range .Path}}
+ <li class="breadcrumb-item"><a href="/admin/ldap/{{.DN}}">{{.Identifier}}</a></li>
+ {{end}}
+ <li class="breadcrumb-item active" aria-current="page">Nouvel objet</li>
+ </ol>
+ </nav>
+</div>
+
{{if .Error}}
<div class="alert alert-danger mt-4">Impossible de créer l'objet.
<div style="font-size: 0.8em">{{ .Error }}</div>
@@ -13,10 +24,12 @@
{{end}}
<form method="POST" class="mt-4">
+ <!--
<div class="form-group">
<label>Parent:</label>
<input type="text" disabled="true" class="form-control" value="{{ .SuperDN }}" />
</div>
+ -->
<div class="form-group">
<label for="idvalue">Identifiant:</label>
<input type="text" id="idvalue" name="idvalue" class="form-control" value="{{ .IdValue }}" />
diff --git a/templates/admin_ldap.html b/templates/admin_ldap.html
index 53570fe..3ceed7d 100644
--- a/templates/admin_ldap.html
+++ b/templates/admin_ldap.html
@@ -21,14 +21,6 @@
</nav>
</div>
-<div class="mt-4">
- <div class="d-flex">
- <a class="ml-auto btn btn-sm btn-success" href="/admin/create/user/{{.DN}}">+utilisateur</a>
- <a class="ml-4 btn btn-sm btn-success" href="/admin/create/group/{{.DN}}">+groupe</a>
- <a class="ml-4 btn btn-sm btn-success" href="/admin/create/generic/{{.DN}}">+objet</a>
- </div>
-</div>
-
<table class="table mt-4">
<tbody>
{{range .Children}}
@@ -44,6 +36,17 @@
</tbody>
</table>
+{{if .CanAddChild}}
+ <div class="mt-4">
+ <div class="d-flex">
+ <a class="ml-auto btn btn-sm btn-success" href="/admin/create/user/{{.DN}}">+utilisateur</a>
+ <a class="ml-4 btn btn-sm btn-success" href="/admin/create/group/{{.DN}}">+groupe</a>
+ <a class="ml-4 btn btn-sm btn-success" href="/admin/create/generic/{{.DN}}">+objet</a>
+ </div>
+ </div>
+ <hr class="mt-4" />
+{{end}}
+
{{if .Success}}
<div class="alert alert-success mt-2">Modification enregistrée.</div>
{{end}}