providers/ldap: fix duplicate attributes (#4972)
closes #4971 Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
01d2cce9ca
commit
ceab1f732d
|
@ -12,3 +12,6 @@ indent_size = 2
|
||||||
|
|
||||||
[*.{yaml,yml}]
|
[*.{yaml,yml}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.go]
|
||||||
|
indent_style = tab
|
||||||
|
|
|
@ -30,11 +30,15 @@ func (pi *ProviderInstance) UserEntry(u api.User) *ldap.Entry {
|
||||||
// Only append attributes that don't already exist
|
// Only append attributes that don't already exist
|
||||||
// TODO: Remove in 2023.3
|
// TODO: Remove in 2023.3
|
||||||
for _, rawAttr := range rawAttrs {
|
for _, rawAttr := range rawAttrs {
|
||||||
|
exists := false
|
||||||
for _, attr := range attrs {
|
for _, attr := range attrs {
|
||||||
if !strings.EqualFold(attr.Name, rawAttr.Name) {
|
if strings.EqualFold(attr.Name, rawAttr.Name) {
|
||||||
attrs = append(attrs, rawAttr)
|
exists = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !exists {
|
||||||
|
attrs = append(attrs, rawAttr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if u.IsActive == nil {
|
if u.IsActive == nil {
|
||||||
|
|
|
@ -36,11 +36,15 @@ func (lg *LDAPGroup) Entry() *ldap.Entry {
|
||||||
// Only append attributes that don't already exist
|
// Only append attributes that don't already exist
|
||||||
// TODO: Remove in 2023.3
|
// TODO: Remove in 2023.3
|
||||||
for _, rawAttr := range rawAttrs {
|
for _, rawAttr := range rawAttrs {
|
||||||
|
exists := false
|
||||||
for _, attr := range attrs {
|
for _, attr := range attrs {
|
||||||
if !strings.EqualFold(attr.Name, rawAttr.Name) {
|
if strings.EqualFold(attr.Name, rawAttr.Name) {
|
||||||
attrs = append(attrs, rawAttr)
|
exists = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !exists {
|
||||||
|
attrs = append(attrs, rawAttr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
objectClass := []string{constants.OCGroup, constants.OCGroupOfUniqueNames, constants.OCGroupOfNames, constants.OCAKGroup, constants.OCPosixGroup}
|
objectClass := []string{constants.OCGroup, constants.OCGroupOfUniqueNames, constants.OCGroupOfNames, constants.OCAKGroup, constants.OCPosixGroup}
|
||||||
|
|
Reference in a new issue