Fixed Change Password Bug

This commit is contained in:
Chris Mann 2023-07-25 09:03:55 +02:00
parent a291232fd8
commit 53a92e2f5c

12
gpas.go
View file

@ -69,6 +69,17 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
user.CN = searchRes.Entries[0].GetAttributeValue("cn") user.CN = searchRes.Entries[0].GetAttributeValue("cn")
user.Mail = searchRes.Entries[0].GetAttributeValue("mail") user.Mail = searchRes.Entries[0].GetAttributeValue("mail")
user.OtherMailbox = searchRes.Entries[0].GetAttributeValue("carLicense") user.OtherMailbox = searchRes.Entries[0].GetAttributeValue("carLicense")
/* Check for outstanding invitation */
searchReq = ldap.NewSearchRequest(user.DN, ldap.ScopeBaseObject,
ldap.NeverDerefAliases, 0, 0, false, "(uid="+user.UID+")", []string{"seeAlso"}, nil)
searchRes, err = ldapConn.Search(searchReq)
if err != nil {
log.Printf(fmt.Sprintf("passwordLost (Check existing invitation) : %v", err))
log.Printf(fmt.Sprintf("passwordLost (Check existing invitation) : %v", user))
log.Printf(fmt.Sprintf("passwordLost (Check existing invitation) : %v", searchRes.Entries[0]))
return err
}
if len(searchRes.Entries == 0) {
/* Add the invitation */ /* Add the invitation */
addReq := ldap.NewAddRequest( addReq := ldap.NewAddRequest(
user.DN, user.DN,
@ -84,6 +95,7 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
log.Printf(fmt.Sprintf("passwordLost 85 : %v", searchRes.Entries[0])) log.Printf(fmt.Sprintf("passwordLost 85 : %v", searchRes.Entries[0]))
return err return err
} }
}
err = passwd(user, config, ldapConn) err = passwd(user, config, ldapConn)
if err != nil { if err != nil {
log.Printf(fmt.Sprintf("passwordLost 90 : %v", err)) log.Printf(fmt.Sprintf("passwordLost 90 : %v", err))