outposts/ldap: allow custom attributes to shadow built-in attributes
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -140,3 +140,26 @@ func (pi *ProviderInstance) GetRIDForGroup(uid string) int32 {
|
||||
|
||||
return int32(gid)
|
||||
}
|
||||
|
||||
func (pi *ProviderInstance) ensureAttributes(attrs []*ldap.EntryAttribute, shouldHave map[string][]string) []*ldap.EntryAttribute {
|
||||
for name, values := range shouldHave {
|
||||
attrs = pi.mustHaveAttribute(attrs, name, values)
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
|
||||
func (pi *ProviderInstance) mustHaveAttribute(attrs []*ldap.EntryAttribute, name string, value []string) []*ldap.EntryAttribute {
|
||||
shouldSet := false
|
||||
for _, attr := range attrs {
|
||||
if attr.Name == name {
|
||||
shouldSet = true
|
||||
}
|
||||
}
|
||||
if shouldSet {
|
||||
return append(attrs, &ldap.EntryAttribute{
|
||||
Name: name,
|
||||
Values: value,
|
||||
})
|
||||
}
|
||||
return attrs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user