From 83cf1f515ba606dc8b6403d3e0894f2f26064738 Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Wed, 26 Jul 2023 13:21:24 +0200 Subject: [PATCH] Refactoring --- model-passwd.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model-passwd.go b/model-passwd.go index 7b58347..3f00ed2 100644 --- a/model-passwd.go +++ b/model-passwd.go @@ -82,12 +82,12 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error { if len(searchRes.Entries) == 0 { /* Add the invitation */ addReq := ldap.NewAddRequest( - "uid="+searchRes.Entries[0].GetAttributeValue("cn")+","+config.InvitationBaseDN, + "uid="+user.CN+","+config.InvitationBaseDN, nil) 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("seeAlso", []string{config.UserNameAttr + "=" + user.UID + "," + config.UserBaseDN}) + addReq.Attribute("seeAlso", []string{config.UserNameAttr + "=" + user.UID + "," + config.InvitationBaseDN}) err = ldapConn.Add(addReq) if err != nil { log.Printf(fmt.Sprintf("passwordLost 83 : %v", err))