|
@@ -130,14 +130,17 @@ func (a *ldapAuther) syncOrgRoles(user *m.User, ldapUser *ldapUserInfo) error {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // remove or update org roles
|
|
|
|
|
|
|
+ // update or remove org roles
|
|
|
for _, org := range orgsQuery.Result {
|
|
for _, org := range orgsQuery.Result {
|
|
|
|
|
+ match := false
|
|
|
|
|
+
|
|
|
for _, group := range a.server.LdapGroups {
|
|
for _, group := range a.server.LdapGroups {
|
|
|
if org.OrgId != group.OrgId {
|
|
if org.OrgId != group.OrgId {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ldapUser.isMemberOf(group.GroupDN) {
|
|
if ldapUser.isMemberOf(group.GroupDN) {
|
|
|
|
|
+ match = true
|
|
|
if org.Role != group.OrgRole {
|
|
if org.Role != group.OrgRole {
|
|
|
// update role
|
|
// update role
|
|
|
cmd := m.UpdateOrgUserCommand{OrgId: org.OrgId, UserId: user.Id, Role: group.OrgRole}
|
|
cmd := m.UpdateOrgUserCommand{OrgId: org.OrgId, UserId: user.Id, Role: group.OrgRole}
|
|
@@ -147,12 +150,14 @@ func (a *ldapAuther) syncOrgRoles(user *m.User, ldapUser *ldapUserInfo) error {
|
|
|
}
|
|
}
|
|
|
// ignore subsequent ldap group mapping matches
|
|
// ignore subsequent ldap group mapping matches
|
|
|
break
|
|
break
|
|
|
- } else {
|
|
|
|
|
- // remove role
|
|
|
|
|
- cmd := m.RemoveOrgUserCommand{OrgId: org.OrgId, UserId: user.Id}
|
|
|
|
|
- if err := bus.Dispatch(&cmd); err != nil {
|
|
|
|
|
- return err
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // remove role if no mappings match
|
|
|
|
|
+ if !match {
|
|
|
|
|
+ cmd := m.RemoveOrgUserCommand{OrgId: org.OrgId, UserId: user.Id}
|
|
|
|
|
+ if err := bus.Dispatch(&cmd); err != nil {
|
|
|
|
|
+ return err
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|