Refactoring

This commit is contained in:
Chris Mann 2023-07-26 13:21:24 +02:00
parent 779a379b89
commit 83cf1f515b

View file

@ -82,12 +82,12 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
if len(searchRes.Entries) == 0 { if len(searchRes.Entries) == 0 {
/* Add the invitation */ /* Add the invitation */
addReq := ldap.NewAddRequest( addReq := ldap.NewAddRequest(
"uid="+searchRes.Entries[0].GetAttributeValue("cn")+","+config.InvitationBaseDN, "uid="+user.CN+","+config.InvitationBaseDN,
nil) nil)
addReq.Attribute("objectClass", []string{"top", "account", "simpleSecurityObject"}) addReq.Attribute("objectClass", []string{"top", "account", "simpleSecurityObject"})
addReq.Attribute("uid", []string{searchRes.Entries[0].GetAttributeValue("cn")}) addReq.Attribute("uid", []string{user.CN})
addReq.Attribute("userPassword", []string{suggestPassword()}) addReq.Attribute("userPassword", []string{suggestPassword()})
addReq.Attribute("seeAlso", []string{config.UserNameAttr + "=" + user.UID + "," + config.UserBaseDN}) addReq.Attribute("seeAlso", []string{config.UserNameAttr + "=" + user.UID + "," + config.InvitationBaseDN})
err = ldapConn.Add(addReq) err = ldapConn.Add(addReq)
if err != nil { if err != nil {
log.Printf(fmt.Sprintf("passwordLost 83 : %v", err)) log.Printf(fmt.Sprintf("passwordLost 83 : %v", err))