Trying a utility file
This commit is contained in:
parent
4986a0ef55
commit
d6f43c17f3
1 changed files with 55 additions and 30 deletions
85
admin.go
85
admin.go
|
@ -74,14 +74,14 @@ func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
sort.Sort(data.Users)
|
sort.Sort(data.Users)
|
||||||
|
|
||||||
addNewUser(NewUser{
|
// addNewUser(NewUser{
|
||||||
DN: "cn=newuser@lesgv.com,ou=newusers,dc=resdigita,dc=org",
|
// DN: "cn=newuser@lesgv.com,ou=newusers,dc=resdigita,dc=org",
|
||||||
CN: "newuser@lesgv.com",
|
// CN: "newuser@lesgv.com",
|
||||||
GivenName: "New",
|
// GivenName: "New",
|
||||||
SN: "User",
|
// SN: "User",
|
||||||
DisplayName: "New User",
|
// DisplayName: "New User",
|
||||||
Mail: "newuser@lesgv.com",
|
// Mail: "newuser@lesgv.com",
|
||||||
}, config, login)
|
// }, config, login)
|
||||||
|
|
||||||
templateAdminUsers.Execute(w, data)
|
templateAdminUsers.Execute(w, data)
|
||||||
}
|
}
|
||||||
|
@ -969,47 +969,72 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
|
||||||
} else if len(data.IdValue) == 0 {
|
} else if len(data.IdValue) == 0 {
|
||||||
data.Error = "No identifier specified"
|
data.Error = "No identifier specified"
|
||||||
} else {
|
} else {
|
||||||
dn := data.IdType + "=" + data.IdValue + "," + super_dn
|
newUser = NewUser{
|
||||||
req := ldap.NewAddRequest(dn, nil)
|
DN: data.IdType + "=" + data.IdValue + "," + super_dn
|
||||||
req.Attribute("objectclass", object_class)
|
}
|
||||||
|
// dn := data.IdType + "=" + data.IdValue + "," + super_dn
|
||||||
|
// req := ldap.NewAddRequest(dn, nil)
|
||||||
|
// req.Attribute("objectclass", object_class)
|
||||||
// req.Attribute("mail", []string{data.IdValue})
|
// req.Attribute("mail", []string{data.IdValue})
|
||||||
/*
|
/*
|
||||||
if data.StructuralObjectClass != "" {
|
if data.StructuralObjectClass != "" {
|
||||||
req.Attribute("structuralobjectclass", []string{data.StructuralObjectClass})
|
req.Attribute("structuralobjectclass", []string{data.StructuralObjectClass})
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if data.DisplayName != "" {
|
if data.CN && data.CN != "" {
|
||||||
req.Attribute("displayname", []string{data.DisplayName})
|
newUser.CN = data.CN }
|
||||||
}
|
if data.UID && data.UID != "" {
|
||||||
if data.GivenName != "" {
|
newUser.UID = data.UID
|
||||||
req.Attribute("givenname", []string{data.GivenName})
|
|
||||||
}
|
}
|
||||||
if data.Mail != "" {
|
if data.Mail != "" {
|
||||||
req.Attribute("mail", []string{data.Mail})
|
newUser.Mail = data.Mail
|
||||||
|
// req.Attribute("mail", []string{data.Mail})
|
||||||
}
|
}
|
||||||
if data.Member != "" {
|
if (data.IdType == "cn") {
|
||||||
req.Attribute("member", []string{data.Member})
|
newUser.CN = data.CN
|
||||||
|
} else if (data.IdType == "mail") {
|
||||||
|
newUser.Mail = data.Mail
|
||||||
|
} else if (data.IdType == "uid") {
|
||||||
|
newUser.UID = data.UID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if data.DisplayName != "" {
|
||||||
|
newUser.DisplayName = data.DisplayName
|
||||||
|
// req.Attribute("displayname", []string{data.DisplayName})
|
||||||
|
}
|
||||||
|
if data.GivenName != "" {
|
||||||
|
newUser.GivenName = data.GivenName
|
||||||
|
// req.Attribute("givenname", []string{data.GivenName})
|
||||||
|
}
|
||||||
|
|
||||||
|
// if data.Member != "" {
|
||||||
|
// req.Attribute("member", []string{data.Member})
|
||||||
|
// }
|
||||||
if data.SN != "" {
|
if data.SN != "" {
|
||||||
req.Attribute("sn", []string{data.SN})
|
newUser.SN = data.SN
|
||||||
|
// req.Attribute("sn", []string{data.SN})
|
||||||
}
|
}
|
||||||
if data.Description != "" {
|
if data.Description != "" {
|
||||||
req.Attribute("description", []string{data.Description})
|
newUser.Description = data.Description
|
||||||
|
// req.Attribute("description", []string{data.Description})
|
||||||
}
|
}
|
||||||
err := login.conn.Add(req)
|
|
||||||
// log.Printf(fmt.Sprintf("899: %v",err))
|
addNewUser(newUser, config, login)
|
||||||
// log.Printf(fmt.Sprintf("899: %v",req))
|
|
||||||
// log.Printf(fmt.Sprintf("899: %v",data))
|
// err := login.conn.Add(req)
|
||||||
if err != nil {
|
// // log.Printf(fmt.Sprintf("899: %v",err))
|
||||||
data.Error = err.Error()
|
// // log.Printf(fmt.Sprintf("899: %v",req))
|
||||||
} else {
|
// // log.Printf(fmt.Sprintf("899: %v",data))
|
||||||
|
// if err != nil {
|
||||||
|
// data.Error = err.Error()
|
||||||
|
// } 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)
|
||||||
|
|
Loading…
Reference in a new issue