mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-24 08:27:27 -04:00
feat(graph/edu): Add externalID user property
This commit is contained in:
@@ -31,11 +31,13 @@ var demoTenants = []tenantWithUsers{
|
||||
DisplayName: libregraph.PtrString("Dennis Ritchie"),
|
||||
OnPremisesSamAccountName: libregraph.PtrString("dennis"),
|
||||
Mail: libregraph.PtrString("dennis@example.org"),
|
||||
ExternalId: libregraph.PtrString("ExternalID1"),
|
||||
},
|
||||
{
|
||||
DisplayName: libregraph.PtrString("Grace Hopper"),
|
||||
OnPremisesSamAccountName: libregraph.PtrString("grace"),
|
||||
Mail: libregraph.PtrString("grace@example.org"),
|
||||
ExternalId: libregraph.PtrString("ExternalID2"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -49,11 +51,13 @@ var demoTenants = []tenantWithUsers{
|
||||
DisplayName: libregraph.PtrString("Albert Einstein"),
|
||||
OnPremisesSamAccountName: libregraph.PtrString("einstein"),
|
||||
Mail: libregraph.PtrString("einstein@example.org"),
|
||||
ExternalId: libregraph.PtrString("ExternalID3"),
|
||||
},
|
||||
{
|
||||
DisplayName: libregraph.PtrString("Marie Curie"),
|
||||
OnPremisesSamAccountName: libregraph.PtrString("marie"),
|
||||
Mail: libregraph.PtrString("marie@example.org"),
|
||||
ExternalId: libregraph.PtrString("ExternalID4"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -12,11 +12,13 @@ import (
|
||||
|
||||
type educationUserAttributeMap struct {
|
||||
primaryRole string
|
||||
externalID string
|
||||
}
|
||||
|
||||
func newEducationUserAttributeMap() educationUserAttributeMap {
|
||||
return educationUserAttributeMap{
|
||||
primaryRole: "userClass",
|
||||
externalID: "openCloudEducationExternalId",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +35,7 @@ func (i *LDAP) CreateEducationUser(ctx context.Context, user libregraph.Educatio
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := i.conn.Add(ar); err != nil {
|
||||
if err = i.conn.Add(ar); err != nil {
|
||||
var lerr *ldap.Error
|
||||
logger.Debug().Err(err).Msg("error adding user")
|
||||
if errors.As(err, &lerr) {
|
||||
@@ -118,6 +120,7 @@ func (i *LDAP) UpdateEducationUser(ctx context.Context, nameOrID string, user li
|
||||
i.userAttributeMap.givenName: user.GetGivenName(),
|
||||
i.userAttributeMap.userType: user.GetUserType(),
|
||||
i.educationConfig.userAttributeMap.primaryRole: user.GetPrimaryRole(),
|
||||
i.educationConfig.userAttributeMap.externalID: user.GetExternalId(),
|
||||
}
|
||||
|
||||
for attribute, value := range properties {
|
||||
@@ -277,6 +280,10 @@ func (i *LDAP) userToEducationUser(user libregraph.User, e *ldap.Entry) *libregr
|
||||
if primaryRole := e.GetEqualFoldAttributeValue(i.educationConfig.userAttributeMap.primaryRole); primaryRole != "" {
|
||||
eduUser.SetPrimaryRole(primaryRole)
|
||||
}
|
||||
|
||||
if externalID := e.GetEqualFoldAttributeValue(i.educationConfig.userAttributeMap.externalID); externalID != "" {
|
||||
eduUser.SetExternalId(externalID)
|
||||
}
|
||||
}
|
||||
|
||||
return eduUser
|
||||
@@ -286,6 +293,10 @@ func (i *LDAP) educationUserToLDAPAttrValues(user libregraph.EducationUser, attr
|
||||
if role, ok := user.GetPrimaryRoleOk(); ok {
|
||||
attrs[i.educationConfig.userAttributeMap.primaryRole] = []string{*role}
|
||||
}
|
||||
|
||||
if externalID, ok := user.GetExternalIdOk(); ok {
|
||||
attrs[i.educationConfig.userAttributeMap.externalID] = []string{*externalID}
|
||||
}
|
||||
attrs["objectClass"] = append(attrs["objectClass"], i.educationConfig.userObjectClass)
|
||||
return attrs, nil
|
||||
}
|
||||
@@ -326,6 +337,7 @@ func (i *LDAP) getEducationUserAttrTypes() []string {
|
||||
i.userAttributeMap.userType,
|
||||
i.userAttributeMap.identities,
|
||||
i.educationConfig.userAttributeMap.primaryRole,
|
||||
i.educationConfig.userAttributeMap.externalID,
|
||||
i.educationConfig.memberOfSchoolAttribute,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ var eduUserAttrs = []string{
|
||||
"userTypeAttribute",
|
||||
"openCloudExternalIdentity",
|
||||
"userClass",
|
||||
"openCloudEducationExternalId",
|
||||
"openCloudMemberOfSchool",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user