diff --git a/office365-user.py b/office365-user.py index 5bd6129..aa6e86c 100755 --- a/office365-user.py +++ b/office365-user.py @@ -285,6 +285,18 @@ def new_or_reactivate_user(ol, dn, new, old): "User creation success. userPrincipalName: %r objectId: %r dn: %s adconnection: %s", new_user["userPrincipalName"], new_user["objectId"], dn, ol.adconnection_alias ) + # update group membership for user on reactivation + if new and old and listener.configRegistry.is_true("office365/groups/sync", False): + for group in udm_user['groups']: + udm_grp = ol.udm.get_udm_group(group) + if udm_grp.get('UniventionOffice365Data'): + azure_data = Office365Listener.decode_o365data(udm_grp['UniventionOffice365Data']) + if ol.adconnection_alias in azure_data: + if 'objectId' in azure_data[ol.adconnection_alias]: + ol.ah.add_objects_to_azure_group(azure_data[ol.adconnection_alias]['objectId'], [new_user["objectId"]]) + else: + # TODO really? + logger.error('need to create azure group %s' % group) def delete_user(ol, dn, new, old):