Add_Directory_and_ProfilePicture #9
6 changed files with 32 additions and 5 deletions
10
directory.go
10
directory.go
|
@ -25,6 +25,7 @@ type SearchResult struct {
|
||||||
Identifiant string `json:"identifiant"`
|
Identifiant string `json:"identifiant"`
|
||||||
erwan marked this conversation as resolved
Outdated
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
erwan marked this conversation as resolved
Outdated
lx
commented
C'est le displayname que tu prends depuis le LDAP? Dans ce cas il faudrait appeller ça C'est le displayname que tu prends depuis le LDAP? Dans ce cas il faudrait appeller ça `DisplayName`
|
|||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
|
Description string `json:"description"`
|
||||||
DN string `json:"dn"`
|
DN string `json:"dn"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,12 +48,12 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//Search value with ldap and filter
|
//Search values with ldap and filter
|
||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
config.UserBaseDN,
|
config.UserBaseDN,
|
||||||
ldap.ScopeSingleLevel, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeSingleLevel, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
"(&(objectclass=organizationalPerson)(visibility=all))",
|
"(&(objectclass=organizationalPerson)(visibility=on))",
|
||||||
[]string{config.UserNameAttr, "displayname", "mail"},
|
[]string{config.UserNameAttr, "displayname", "mail", "description"},
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
sr, err := login.conn.Search(searchRequest)
|
sr, err := login.conn.Search(searchRequest)
|
||||||
|
@ -71,6 +72,7 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
Identifiant: values.GetAttributeValue("cn"),
|
Identifiant: values.GetAttributeValue("cn"),
|
||||||
Name: values.GetAttributeValue("displayname"),
|
Name: values.GetAttributeValue("displayname"),
|
||||||
Email: values.GetAttributeValue("email"),
|
Email: values.GetAttributeValue("email"),
|
||||||
|
Description: values.GetAttributeValue("description"),
|
||||||
DN: values.DN,
|
DN: values.DN,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
@ -78,7 +80,7 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Convert interface to uint32 with Type Assertions and not a simple convert
|
//Convert interface to uint32 with Type Assertions and not a simple convert for messageID
|
||||||
if val_Raw, ok_raw := session.Values["MessageID"]; ok_raw {
|
if val_Raw, ok_raw := session.Values["MessageID"]; ok_raw {
|
||||||
if val, ok := val_Raw.(uint32); ok {
|
if val, ok := val_Raw.(uint32); ok {
|
||||||
val += 1
|
val += 1
|
||||||
|
|
2
main.go
2
main.go
|
@ -244,7 +244,7 @@ func checkLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
||||||
login_info.DN,
|
login_info.DN,
|
||||||
ldap.ScopeBaseObject, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeBaseObject, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
requestKind,
|
requestKind,
|
||||||
[]string{"dn", "displayname", "givenname", "sn", "mail", "memberof"},
|
[]string{"dn", "displayname", "givenname", "sn", "mail", "memberof", "visibility", "description"},
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
sr, err := l.Search(searchRequest)
|
sr, err := l.Search(searchRequest)
|
||||||
|
|
|
@ -16,6 +16,8 @@ type ProfileTplData struct {
|
||||||
DisplayName string
|
DisplayName string
|
||||||
GivenName string
|
GivenName string
|
||||||
Surname string
|
Surname string
|
||||||
|
Visibility string
|
||||||
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleProfile(w http.ResponseWriter, r *http.Request) {
|
func handleProfile(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -36,6 +38,8 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
|
||||||
data.DisplayName = login.UserEntry.GetAttributeValue("displayname")
|
data.DisplayName = login.UserEntry.GetAttributeValue("displayname")
|
||||||
data.GivenName = login.UserEntry.GetAttributeValue("givenname")
|
data.GivenName = login.UserEntry.GetAttributeValue("givenname")
|
||||||
data.Surname = login.UserEntry.GetAttributeValue("sn")
|
data.Surname = login.UserEntry.GetAttributeValue("sn")
|
||||||
|
data.Visibility = login.UserEntry.GetAttributeValue("visibility")
|
||||||
|
data.Description = login.UserEntry.GetAttributeValue("description")
|
||||||
|
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
@ -43,11 +47,15 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
|
||||||
data.DisplayName = strings.TrimSpace(strings.Join(r.Form["display_name"], ""))
|
data.DisplayName = strings.TrimSpace(strings.Join(r.Form["display_name"], ""))
|
||||||
data.GivenName = strings.TrimSpace(strings.Join(r.Form["given_name"], ""))
|
data.GivenName = strings.TrimSpace(strings.Join(r.Form["given_name"], ""))
|
||||||
data.Surname = strings.TrimSpace(strings.Join(r.Form["surname"], ""))
|
data.Surname = strings.TrimSpace(strings.Join(r.Form["surname"], ""))
|
||||||
|
data.Description = strings.Trim(strings.Join(r.Form["description"], ""), "")
|
||||||
|
data.Visibility = strings.TrimSpace(strings.Join(r.Form["visibility"], ""))
|
||||||
|
|
||||||
modify_request := ldap.NewModifyRequest(login.Info.DN, nil)
|
modify_request := ldap.NewModifyRequest(login.Info.DN, nil)
|
||||||
modify_request.Replace("displayname", []string{data.DisplayName})
|
modify_request.Replace("displayname", []string{data.DisplayName})
|
||||||
modify_request.Replace("givenname", []string{data.GivenName})
|
modify_request.Replace("givenname", []string{data.GivenName})
|
||||||
modify_request.Replace("sn", []string{data.Surname})
|
modify_request.Replace("sn", []string{data.Surname})
|
||||||
|
modify_request.Replace("description", []string{data.Description})
|
||||||
|
modify_request.Replace("visibility", []string{data.Visibility})
|
||||||
|
|
||||||
err := login.conn.Modify(modify_request)
|
err := login.conn.Modify(modify_request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -23,9 +23,13 @@ function searchDirectory() {
|
||||||
var identifiant = row.insertCell(0);
|
var identifiant = row.insertCell(0);
|
||||||
var name = row.insertCell(1);
|
var name = row.insertCell(1);
|
||||||
var email = row.insertCell(2);
|
var email = row.insertCell(2);
|
||||||
|
var description = row.insertCell(3);
|
||||||
|
description.setAttribute("style", "word-break: break-all;");
|
||||||
|
|
||||||
identifiant.innerHTML = `<a href="/admin/ldap/${jsonResponse.search[i].dn}">${jsonResponse.search[i].identifiant}</a>`
|
identifiant.innerHTML = `<a href="/admin/ldap/${jsonResponse.search[i].dn}">${jsonResponse.search[i].identifiant}</a>`
|
||||||
name.innerHTML = jsonResponse.search[i].name
|
name.innerHTML = jsonResponse.search[i].name
|
||||||
email.innerHTML = jsonResponse.search[i].email
|
email.innerHTML = jsonResponse.search[i].email
|
||||||
|
description.innerHTML = `${jsonResponse.search[i].description}`
|
||||||
|
|
||||||
}
|
}
|
||||||
old_table.parentNode.replaceChild(table, old_table)
|
old_table.parentNode.replaceChild(table, old_table)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<th scope="col">Identifiant</th>
|
<th scope="col">Identifiant</th>
|
||||||
<th scope="col">Nom complet</th>
|
<th scope="col">Nom complet</th>
|
||||||
<th scope="col">Email</th>
|
<th scope="col">Email</th>
|
||||||
|
<th scope="col">Description</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="users">
|
<tbody id="users">
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,18 @@
|
||||||
<label for="surname">Nom de famille:</label>
|
<label for="surname">Nom de famille:</label>
|
||||||
<input type="text" id="surname" name="surname" class="form-control" value="{{ .Surname }}" />
|
<input type="text" id="surname" name="surname" class="form-control" value="{{ .Surname }}" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description">Description (180 caractères maximum)</label>
|
||||||
|
<textarea id="description" name="description" class="form-control" maxlength="180">{{ .Description }}</textarea>
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-check">
|
||||||
|
{{if .Visibility}}
|
||||||
|
<input class="form-check-input" name="visibility" type="checkbox" id="visibility" checked>
|
||||||
|
{{else}}
|
||||||
|
<input class="form-check-input" name="visibility" type="checkbox" id="visibility">
|
||||||
|
{{end}}
|
||||||
|
<label class="form-check-label" for="visibility">Apparaît sur l'annuaire</label>
|
||||||
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Enregistrer les modifications</button>
|
<button type="submit" class="btn btn-primary">Enregistrer les modifications</button>
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue
L'identifiant, c'est le CN ? Dans tous les cas
Identifiant
c'est un mot français, il faudrait appeller ça plutôt justeId
.