I think the group management probably didn't work
This commit is contained in:
parent
2c5bb1ebd6
commit
a480ebbe36
148
admin.go
148
admin.go
@ -431,6 +431,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
|
|||||||
Active: dn == config.BaseDN,
|
Active: dn == config.BaseDN,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
log.Printf(fmt.Sprintf("434: %v",path))
|
||||||
|
|
||||||
len_base_dn := len(strings.Split(config.BaseDN, ","))
|
len_base_dn := len(strings.Split(config.BaseDN, ","))
|
||||||
dn_split := strings.Split(dn, ",")
|
dn_split := strings.Split(dn, ",")
|
||||||
@ -442,6 +443,8 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
|
|||||||
Active: i == len(dn_split),
|
Active: i == len(dn_split),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.Printf(fmt.Sprintf("446: %v",path))
|
||||||
|
|
||||||
|
|
||||||
// Handle modification operation
|
// Handle modification operation
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
@ -563,6 +566,8 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
|
|||||||
nil)
|
nil)
|
||||||
|
|
||||||
sr, err := login.conn.Search(searchRequest)
|
sr, err := login.conn.Search(searchRequest)
|
||||||
|
log.Printf(fmt.Sprintf("569: %v",searchRequest))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@ -617,7 +622,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
hasMembers, hasGroups, isOrganization := false, false, false
|
hasMembers, hasGroups, isOrganization := false, false, false
|
||||||
for _, oc := range objectClass {
|
for _, oc := range objectClass {
|
||||||
if strings.EqualFold(oc, "organizationalperson") || strings.EqualFold(oc, "person") {
|
if strings.EqualFold(oc, "organizationalPerson") || strings.EqualFold(oc, "person") || strings.EqualFold(oc, "inetOrgPerson") {
|
||||||
hasGroups = true
|
hasGroups = true
|
||||||
}
|
}
|
||||||
if strings.EqualFold(oc, "groupOfNames") {
|
if strings.EqualFold(oc, "groupOfNames") {
|
||||||
@ -682,59 +687,102 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse group list and prepare form section
|
// // Parse group list and prepare form section
|
||||||
groups_dn := []string{}
|
// groups_dn := []string{}
|
||||||
if gp, ok := props["memberof"]; ok {
|
// if gp, ok := props["memberof"]; ok {
|
||||||
groups_dn = gp.Values
|
// groups_dn = gp.Values
|
||||||
delete(props, "memberof")
|
// delete(props, "memberof")
|
||||||
}
|
// }
|
||||||
|
|
||||||
groups := []EntryName{}
|
groups := []EntryName{}
|
||||||
possibleNewGroups := []EntryName{}
|
possibleNewGroups := []EntryName{}
|
||||||
if len(groups_dn) > 0 || hasGroups {
|
searchRequest = ldap.NewSearchRequest(
|
||||||
// Lookup all existing groups in the server
|
config.GroupBaseDN,
|
||||||
// to know the DN -> display name correspondance
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
searchRequest = ldap.NewSearchRequest(
|
fmt.Sprintf("(&(objectClass=groupOfNames)(member=%s))",dn),
|
||||||
config.GroupBaseDN,
|
[]string{"dn", "displayName", "cn", "description"},
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
nil)
|
||||||
fmt.Sprintf("(objectClass=groupOfNames)"),
|
log.Printf(fmt.Sprintf("708: %v",searchRequest))
|
||||||
[]string{"dn", "description"},
|
sr, err = login.conn.Search(searchRequest)
|
||||||
nil)
|
if err != nil {
|
||||||
sr, err = login.conn.Search(searchRequest)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
if err != nil {
|
return
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
groupMap := make(map[string]string)
|
|
||||||
for _, ent := range sr.Entries {
|
|
||||||
groupMap[ent.DN] = ent.GetAttributeValue("displayname")
|
|
||||||
if groupMap[ent.DN] == "" {
|
|
||||||
groupMap[ent.DN] = ent.GetAttributeValue("description")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate list of current groups
|
|
||||||
for _, grpdn := range groups_dn {
|
|
||||||
groups = append(groups, EntryName{
|
|
||||||
DN: grpdn,
|
|
||||||
Name: groupMap[grpdn],
|
|
||||||
})
|
|
||||||
delete(groupMap, grpdn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate list of possible new groups
|
|
||||||
for dn, name := range groupMap {
|
|
||||||
entry := EntryName{
|
|
||||||
DN: dn,
|
|
||||||
Name: name,
|
|
||||||
}
|
|
||||||
if entry.Name == "" {
|
|
||||||
entry.Name = entry.DN
|
|
||||||
}
|
|
||||||
possibleNewGroups = append(possibleNewGroups, entry)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
log.Printf(fmt.Sprintf("714: %v",sr.Entries))
|
||||||
|
for _, ent := range sr.Entries {
|
||||||
|
groups = append(groups, EntryName{
|
||||||
|
DN: ent.DN,
|
||||||
|
Name: ent.GetAttributeValue("cn"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
searchRequest = ldap.NewSearchRequest(
|
||||||
|
config.GroupBaseDN,
|
||||||
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
|
fmt.Sprintf("(&(objectClass=groupOfNames)(!(member=%s)))",dn),
|
||||||
|
[]string{"dn", "displayName", "cn", "description"},
|
||||||
|
nil)
|
||||||
|
log.Printf(fmt.Sprintf("724: %v",searchRequest))
|
||||||
|
sr, err = login.conn.Search(searchRequest)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf(fmt.Sprintf("714: %v",sr.Entries))
|
||||||
|
for _, ent := range sr.Entries {
|
||||||
|
possibleNewGroups = append(possibleNewGroups, EntryName{
|
||||||
|
DN: ent.DN,
|
||||||
|
Name: ent.GetAttributeValue("cn"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// possibleNewGroup.DN = ent.GetAttributeValue("dn")
|
||||||
|
// possibleNewGroup.Name = ent.GetAttributeValue("cn")
|
||||||
|
// log.Printf(fmt.Sprintf("725: %v %v",dn, ent.GetAttributeValue("member")))
|
||||||
|
// for _, member := range ent .GetAttributeValue("member") {
|
||||||
|
// // log.Printf(fmt.Sprintf("725: %v %v",dn, member))
|
||||||
|
// if ent.GetAttributeValue("member") == dn {
|
||||||
|
// groups = append(groups,possibleNewGroup,)
|
||||||
|
// possibleNewGroup.DN = ""
|
||||||
|
// possibleNewGroup.Name = ""
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
// if possibleNewGroup.DN != "" {
|
||||||
|
// possibleNewGroups = append(possibleNewGroups,possibleNewGroup,)
|
||||||
|
// possibleNewGroup = EntryName{}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// groupMap[.DN] = ent.GetAttributeValue("displayName")
|
||||||
|
// if groupMap[.DN] == "" {
|
||||||
|
// groupMap[.DN] = ent.GetAttributeValue("cn")
|
||||||
|
// }
|
||||||
|
// if groupMap[.DN] == "" {
|
||||||
|
// groupMap[.DN] = ent.GetAttributeValue("description")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Calculate list of current groups
|
||||||
|
// log.Printf(fmt.Sprintf("%v",groups_dn))
|
||||||
|
// for _, grpdn := range groups_dn {
|
||||||
|
// log.Printf(fmt.Sprintf("%v",grpdn))
|
||||||
|
// groups = append(groups, EntryName{
|
||||||
|
// DN: grpdn,
|
||||||
|
// Name: groupMap[grpdn],
|
||||||
|
// })
|
||||||
|
// delete(groupMap, grpdn)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Calculate list of possible new groups
|
||||||
|
// for dn, name := range groupMap {
|
||||||
|
// entry := EntryName{
|
||||||
|
// DN: dn,
|
||||||
|
// Name: name,
|
||||||
|
// }
|
||||||
|
// if entry.Name == "" {
|
||||||
|
// entry.Name = entry.DN
|
||||||
|
// }
|
||||||
|
// possibleNewGroups = append(possibleNewGroups, entry)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// Get children
|
// Get children
|
||||||
searchRequest = ldap.NewSearchRequest(
|
searchRequest = ldap.NewSearchRequest(
|
||||||
|
@ -8,5 +8,4 @@ function addResDigitaOrgIdValue () {
|
|||||||
function addResDigitaOrgMail () {
|
function addResDigitaOrgMail () {
|
||||||
document.getElementById("idvalue").value = addResDigitaOrg("mail");
|
document.getElementById("idvalue").value = addResDigitaOrg("mail");
|
||||||
}
|
}
|
||||||
document.getElementById("mail").addEventListener("change",addResDigitaOrgMail);
|
|
||||||
document.getElementById("idvalue").addEventListener("change",addResDigitaOrgIdValue);
|
document.getElementById("idvalue").addEventListener("change",addResDigitaOrgIdValue);
|
Loading…
Reference in New Issue
Block a user