Trying a utility file

This commit is contained in:
Chris Mann 2023-07-20 12:25:22 +02:00
parent d6f43c17f3
commit 80aaa8263b

View file

@ -970,7 +970,7 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
data.Error = "No identifier specified" data.Error = "No identifier specified"
} else { } else {
newUser = NewUser{ newUser = NewUser{
DN: data.IdType + "=" + data.IdValue + "," + super_dn DN: data.IdType + "=" + data.IdValue + "," + super_dn,
} }
// dn := data.IdType + "=" + data.IdValue + "," + super_dn // dn := data.IdType + "=" + data.IdValue + "," + super_dn
// req := ldap.NewAddRequest(dn, nil) // req := ldap.NewAddRequest(dn, nil)
@ -981,21 +981,16 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
req.Attribute("structuralobjectclass", []string{data.StructuralObjectClass}) req.Attribute("structuralobjectclass", []string{data.StructuralObjectClass})
} }
*/ */
if data.CN && data.CN != "" {
newUser.CN = data.CN }
if data.UID && data.UID != "" {
newUser.UID = data.UID
}
if data.Mail != "" { if data.Mail != "" {
newUser.Mail = data.Mail newUser.Mail = data.Mail
// req.Attribute("mail", []string{data.Mail}) // req.Attribute("mail", []string{data.Mail})
} }
if (data.IdType == "cn") { if data.IdType == "cn" {
newUser.CN = data.CN newUser.CN = data.IdValue
} else if (data.IdType == "mail") { } else if data.IdType == "mail" {
newUser.Mail = data.Mail newUser.Mail = data.IdValue
} else if (data.IdType == "uid") { } else if data.IdType == "uid" {
newUser.UID = data.UID newUser.UID = data.IdValue
} }
if data.DisplayName != "" { if data.DisplayName != "" {
@ -1028,13 +1023,13 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
// if err != nil { // if err != nil {
// data.Error = err.Error() // data.Error = err.Error()
// } else { // } else {
if template == "ml" { if template == "ml" {
http.Redirect(w, r, "/admin/mailing/"+data.IdValue, http.StatusFound) http.Redirect(w, r, "/admin/mailing/"+data.IdValue, http.StatusFound)
} else { } else {
http.Redirect(w, r, "/admin/ldap/"+dn, http.StatusFound) http.Redirect(w, r, "/admin/ldap/"+dn, http.StatusFound)
} }
// } // }
// } }
} }
templateAdminCreate.Execute(w, data) templateAdminCreate.Execute(w, data)