diff --git a/admin.go b/admin.go index 2cd8d33..0e3c66e 100644 --- a/admin.go +++ b/admin.go @@ -45,6 +45,34 @@ type AdminUsersTplData struct { Users EntryList } +func handleAdminActivateUsers(w http.ResponseWriter, r *http.Request) { + templateAdminActivateUsers := getTemplate("admin_activate.html") + login := checkAdminLogin(w, r) + if login == nil { + return + } + searchRequest := ldap.NewSearchRequest( + config.InvitationBaseDN, + ldap.ScopeSingleLevel, ldap.NeverDerefAliases, 0, 0, false, + fmt.Sprintf("(&(objectClass=organizationalPerson))"), + []string{config.UserNameAttr, "dn", "displayName", "givenName", "sn", "mail", "uid", "cn"}, + nil) + + sr, err := login.conn.Search(searchRequest) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + data := &AdminUsersTplData{ + Login: login, + UserNameAttr: config.UserNameAttr, + UserBaseDN: config.UserBaseDN, + Users: EntryList(sr.Entries), + } + templateAdminActivateUsers.Execute(w, data) +} + func handleAdminUsers(w http.ResponseWriter, r *http.Request) { templateAdminUsers := getTemplate("admin_users.html") diff --git a/main.go b/main.go index b9294d5..9f62faa 100644 --- a/main.go +++ b/main.go @@ -61,6 +61,8 @@ func main() { r.HandleFunc("/passwd", handlePasswd) r.HandleFunc("/picture/{name}", handleDownloadPicture) + r.HandleFunc("/admin/activate", handleAdminActivateUsers) + r.HandleFunc("/directory/search", handleDirectorySearch) r.HandleFunc("/directory", handleDirectory) diff --git a/templates/admin_activate.html b/templates/admin_activate.html new file mode 100644 index 0000000..0b0be97 --- /dev/null +++ b/templates/admin_activate.html @@ -0,0 +1,25 @@ +{{define "title"}}Activer des utilisateurs |{{end}} + + + + + + + + {{with $root := .}} + {{range $user := $root.Users}} + + + + + + + + {{end}} + {{end}} + +
IdentifiantNom complet
+ + {{$user.GetAttributeValue $user.UserNameAttr}} + + {{$user.GetAttributeValue "mail"}}{{$user.GetAttributeValue "displayname"}}{{$user.GetAttributeValue "sn"}}{{$user.GetAttributeValue "description"}}
\ No newline at end of file