예제 #1
0
 private void ThrowIfPartialSuccess(UpdateUnifiedGroupTask.UpdateAADLinkResults results)
 {
     if (results != null && results.ContainsFailure())
     {
         base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.AADUpdate;
         AADPartialFailureException ex = new AADPartialFailureException(string.Format("Partially failed to update group: {0}", this.ExternalDirectoryObjectId ?? this.SmtpAddress))
         {
             FailedAddedMembers          = this.GetOriginalFailedLinks(results.FailedAddedMembers),
             FailedRemovedMembers        = this.GetOriginalFailedLinks(results.FailedRemovedMembers),
             FailedAddedOwners           = this.GetOriginalFailedLinks(results.FailedAddedOwners),
             FailedRemovedOwners         = this.GetOriginalFailedLinks(results.FailedRemovedOwners),
             FailedAddedPendingMembers   = this.GetOriginalFailedLinks(results.FailedAddedPendingMembers),
             FailedRemovedPendingMembers = this.GetOriginalFailedLinks(results.FailedRemovedPendingMembers)
         };
         throw ex;
     }
 }
예제 #2
0
 protected override void RunInternal()
 {
     UnifiedGroupsTask.Tracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: User {1} is updating group {2}", base.ActivityId, this.accessingPrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), this.ExternalDirectoryObjectId ?? this.SmtpAddress);
     base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.ResolveExternalIdentities;
     if (base.IsAADEnabled || base.IsSharePointEnabled)
     {
         this.GetIdentitiesForParameters();
     }
     UpdateUnifiedGroupTask.UpdateAADLinkResults updateAADLinkResults = null;
     base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.AADUpdate;
     if (base.IsAADEnabled)
     {
         UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: Updating group in AAD", base.ActivityId);
         updateAADLinkResults = this.UpdateAAD();
         UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: Finished updating group in AAD", base.ActivityId);
         base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.SharePointUpdate;
         if (base.IsSharePointEnabled)
         {
             UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: Enqueueing job to notify SharePoint about group update", base.ActivityId);
             UpdateSiteCollectionTask task = new UpdateSiteCollectionTask(base.AccessingUser, base.ADSession, base.ActivityId)
             {
                 Description               = this.Description,
                 DisplayName               = this.DisplayName,
                 AddedOwners               = this.GetSucceededLinkExternalIds(this.addedOwnersIdentities, updateAADLinkResults.FailedAddedOwners),
                 RemovedOwners             = this.GetSucceededLinkExternalIds(this.removedOwnersIdentities, updateAADLinkResults.FailedRemovedOwners),
                 AddedMembers              = this.GetSucceededLinkExternalIds(this.addedMembersIdentities, updateAADLinkResults.FailedAddedMembers),
                 RemovedMembers            = this.GetSucceededLinkExternalIds(this.removedMembersIdentities, updateAADLinkResults.FailedRemovedMembers),
                 ExternalDirectoryObjectId = this.ExternalDirectoryObjectId
             };
             bool flag = UnifiedGroupsTask.QueueTask(task);
             UnifiedGroupsTask.Tracer.TraceDebug <Guid, bool>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: Finished enqueueing job to notify SharePoint about group update. queued: {1}", base.ActivityId, flag);
             if (!flag)
             {
                 UnifiedGroupsTask.Tracer.TraceError <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: Failed to queue job to notify SharePoint about group update", base.ActivityId);
                 FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
                 {
                     {
                         FederatedDirectoryLogSchema.TraceTag.TaskName,
                         this.TaskName
                     },
                     {
                         FederatedDirectoryLogSchema.TraceTag.ActivityId,
                         base.ActivityId
                     },
                     {
                         FederatedDirectoryLogSchema.TraceTag.CurrentAction,
                         base.CurrentAction
                     },
                     {
                         FederatedDirectoryLogSchema.TraceTag.Message,
                         "Failed to queue job to notify SharePoint about group update. ExternalDirectoryObjectId: " + this.ExternalDirectoryObjectId
                     }
                 });
             }
         }
         else
         {
             UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: SharePoint is not enabled, skipping notification about group creation", base.ActivityId);
         }
     }
     base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.ExchangeUpdate;
     UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: Updating group in Exchange", base.ActivityId);
     try
     {
         this.UpdateGroupMailbox(updateAADLinkResults);
     }
     catch (ExchangeAdaptorException arg)
     {
         if (updateAADLinkResults == null || !updateAADLinkResults.ContainsFailure())
         {
             throw;
         }
         FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
         {
             {
                 FederatedDirectoryLogSchema.TraceTag.TaskName,
                 this.TaskName
             },
             {
                 FederatedDirectoryLogSchema.TraceTag.ActivityId,
                 base.ActivityId
             },
             {
                 FederatedDirectoryLogSchema.TraceTag.CurrentAction,
                 base.CurrentAction
             },
             {
                 FederatedDirectoryLogSchema.TraceTag.Message,
                 string.Format("AAD partially failed and Exchange threw an exception. ExternalDirectoryObjectId: {0}, {1}", this.ExternalDirectoryObjectId ?? this.SmtpAddress, arg)
             }
         });
     }
     UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: Finished updating group in Exchange", base.ActivityId);
     FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
     {
         {
             FederatedDirectoryLogSchema.TraceTag.TaskName,
             this.TaskName
         },
         {
             FederatedDirectoryLogSchema.TraceTag.ActivityId,
             base.ActivityId
         },
         {
             FederatedDirectoryLogSchema.TraceTag.CurrentAction,
             base.CurrentAction
         },
         {
             FederatedDirectoryLogSchema.TraceTag.Message,
             string.Format("Updated group. ExternalDirectoryObjectId: {0}, By: {1}", this.ExternalDirectoryObjectId ?? this.SmtpAddress, this.accessingPrincipal.MailboxInfo.PrimarySmtpAddress.ToString())
         }
     });
     this.ThrowIfPartialSuccess(updateAADLinkResults);
     base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.Completed;
 }