protected override void RunInternal()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.SharePointUpdate;
            UnifiedGroupsTask.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "ActivityId={0}. UpdateSiteCollectionTask.RunInternal: Notifying SharePoint about group update: {1}", base.ActivityId, this.ExternalDirectoryObjectId);
            this.UpdateSiteCollection();
            UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. UpdateSiteCollectionTask.RunInternal: Finished notifying SharePoint about group update", base.ActivityId);
            string value = string.Format("Notified SharePoint about group update;Group={0};ElapsedTime={1}", this.ExternalDirectoryObjectId, stopwatch.ElapsedMilliseconds);

            FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
            {
                {
                    FederatedDirectoryLogSchema.TraceTag.TaskName,
                    this.TaskName
                },
                {
                    FederatedDirectoryLogSchema.TraceTag.ActivityId,
                    base.ActivityId
                },
                {
                    FederatedDirectoryLogSchema.TraceTag.CurrentAction,
                    base.CurrentAction
                },
                {
                    FederatedDirectoryLogSchema.TraceTag.Message,
                    value
                }
            });
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.Completed;
        }
示例#2
0
 protected override void RunInternal()
 {
     base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.ExchangeDelete;
     UnifiedGroupsTask.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.RunInternal: Deleting group in Exchange: {1}", base.ActivityId, this.ExternalDirectoryObjectId ?? this.SmtpAddress);
     this.DeleteGroupMailbox();
     UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.RunInternal: Finished deleting 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("Deleted group mailbox in Exchange. {0}", this.ExternalDirectoryObjectId ?? this.SmtpAddress)
         }
     });
     base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.Completed;
 }
示例#3
0
 private void GetIdentitiesForParameters()
 {
     this.identityMapping = new ObjectIdMapping(base.ADSession);
     this.identityMapping.Prefetch(new string[]
     {
         this.SmtpAddress
     });
     this.identityMapping.Prefetch(this.AddedOwners);
     this.identityMapping.Prefetch(this.RemovedOwners);
     this.identityMapping.Prefetch(this.AddedMembers);
     this.identityMapping.Prefetch(this.RemovedMembers);
     this.identityMapping.Prefetch(this.AddedPendingMembers);
     this.identityMapping.Prefetch(this.RemovedPendingMembers);
     if (string.IsNullOrEmpty(this.ExternalDirectoryObjectId))
     {
         this.ExternalDirectoryObjectId = this.identityMapping.GetIdentityFromSmtpAddress(this.SmtpAddress);
     }
     this.addedMembersIdentities          = this.identityMapping.GetIdentitiesFromSmtpAddresses(this.AddedMembers);
     this.removedMembersIdentities        = this.identityMapping.GetIdentitiesFromSmtpAddresses(this.RemovedMembers);
     this.addedOwnersIdentities           = this.identityMapping.GetIdentitiesFromSmtpAddresses(this.AddedOwners);
     this.removedOwnersIdentities         = this.identityMapping.GetIdentitiesFromSmtpAddresses(this.RemovedOwners);
     this.addedPendingMembersIdentities   = this.identityMapping.GetIdentitiesFromSmtpAddresses(this.AddedPendingMembers);
     this.removedPendingMembersIdentities = this.identityMapping.GetIdentitiesFromSmtpAddresses(this.RemovedPendingMembers);
     if (this.identityMapping.InvalidSmtpAddresses.Count > 0)
     {
         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("Unable to parse identities as SMTP Addresses: {0}", string.Join(",", this.identityMapping.InvalidSmtpAddresses))
             }
         });
     }
 }
示例#4
0
 private static void LogEntry(string message)
 {
     FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
     {
         {
             FederatedDirectoryLogSchema.TraceTag.TaskName,
             "WarmupGroupManagementDependency"
         },
         {
             FederatedDirectoryLogSchema.TraceTag.ActivityId,
             "3ca7a0ab-9404-497f-b691-000000000000"
         },
         {
             FederatedDirectoryLogSchema.TraceTag.CurrentAction,
             "WarmupGroupManagementDependency"
         },
         {
             FederatedDirectoryLogSchema.TraceTag.Message,
             message
         }
     });
 }
示例#5
0
 protected static bool QueueTask(UnifiedGroupsTask task)
 {
     return(ThreadPool.QueueUserWorkItem(delegate(object state)
     {
         try
         {
             GrayException.MapAndReportGrayExceptions(delegate()
             {
                 task.RunWithLogging();
             });
         }
         catch (GrayException arg)
         {
             UnifiedGroupsTask.Tracer.TraceError <Guid, GrayException>(0L, "ActivityId: {0}. GrayException: {1}", task.ActivityId, arg);
             FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
             {
                 {
                     FederatedDirectoryLogSchema.TraceTag.TaskName,
                     task.TaskName
                 },
                 {
                     FederatedDirectoryLogSchema.TraceTag.ActivityId,
                     task.ActivityId
                 },
                 {
                     FederatedDirectoryLogSchema.TraceTag.CurrentAction,
                     task.CurrentAction
                 },
                 {
                     FederatedDirectoryLogSchema.TraceTag.Message,
                     "GrayException: " + arg
                 }
             });
         }
     }));
 }
示例#6
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;
 }
示例#7
0
        protected override void RunInternal()
        {
            this.CreationDiagnostics.Start();
            UnifiedGroupsTask.Tracer.TraceDebug((long)this.GetHashCode(), "ActivityId={0}. UpdateUnifiedGroupTask.Run: User {1} is creating a group. Name: {2}, Alias: {3}", new object[]
            {
                base.ActivityId,
                this.accessingPrincipal.MailboxInfo.PrimarySmtpAddress.ToString(),
                this.Name,
                this.Alias
            });
            this.CreationDiagnostics.CmdletLogCorrelationId = base.ActivityId;
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.AADCreate;
            UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Creating group in AAD", base.ActivityId);
            this.ExternalDirectoryObjectId = this.CreateAAD();
            UnifiedGroupsTask.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Finished creating group in AAD. ExternalDirectoryObjectId: {1}", base.ActivityId, this.ExternalDirectoryObjectId);
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.AADAddOwnerAsMember;
            UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Adding owner as member in AAD", base.ActivityId);
            try
            {
                this.AddOwnerAsMember(this.ExternalDirectoryObjectId, base.AccessingUser.ExternalDirectoryObjectId);
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Finished adding owner as member in AAD", base.ActivityId);
            }
            catch (AADException ex)
            {
                UnifiedGroupsTask.Tracer.TraceError <Guid, AADException>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Adding owner as member in AAD failed: {1}", base.ActivityId, ex);
                FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.ExceptionTag>
                {
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.TaskName,
                        this.TaskName
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ActivityId,
                        base.ActivityId
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ExceptionType,
                        ex.GetType()
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ExceptionDetail,
                        ex
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.CurrentAction,
                        base.CurrentAction
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.Message,
                        "Adding owner as member in AAD failed"
                    }
                });
            }
            this.CreationDiagnostics.RecordAADTime();
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.AADCompleteCallback;
            if (this.AADComplete != null)
            {
                try
                {
                    UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Calling AADComplete", base.ActivityId);
                    this.AADComplete();
                    UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Finished calling AADComplete", base.ActivityId);
                }
                catch (LocalizedException ex2)
                {
                    UnifiedGroupsTask.Tracer.TraceError <Guid, LocalizedException>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: AADComplete event failed: {1}", base.ActivityId, ex2);
                    FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.ExceptionTag>
                    {
                        {
                            FederatedDirectoryLogSchema.ExceptionTag.TaskName,
                            this.TaskName
                        },
                        {
                            FederatedDirectoryLogSchema.ExceptionTag.ActivityId,
                            base.ActivityId
                        },
                        {
                            FederatedDirectoryLogSchema.ExceptionTag.ExceptionType,
                            ex2.GetType()
                        },
                        {
                            FederatedDirectoryLogSchema.ExceptionTag.ExceptionDetail,
                            ex2
                        },
                        {
                            FederatedDirectoryLogSchema.ExceptionTag.CurrentAction,
                            base.CurrentAction
                        },
                        {
                            FederatedDirectoryLogSchema.ExceptionTag.Message,
                            "AADComplete event failed"
                        }
                    });
                }
            }
            this.CreationDiagnostics.RecordAADCompleteCallbackTime();
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.SharePointCreate;
            if (base.IsSharePointEnabled)
            {
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Queuing job to notify SharePoint about group creation", base.ActivityId);
                CreateSiteCollectionTask task = new CreateSiteCollectionTask(base.AccessingUser, base.ADSession, base.ActivityId)
                {
                    Name        = this.Name,
                    Alias       = this.Alias,
                    Description = this.Description,
                    Type        = this.Type,
                    ExternalDirectoryObjectId = this.ExternalDirectoryObjectId
                };
                bool flag = UnifiedGroupsTask.QueueTask(task);
                UnifiedGroupsTask.Tracer.TraceDebug <Guid, bool>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Finished queuing job to notify SharePoint about group creation. queued: {1}", base.ActivityId, flag);
                if (!flag)
                {
                    UnifiedGroupsTask.Tracer.TraceError <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Failed to queue job to notify SharePoint about group creation", 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 creation. ExternalDirectoryObjectId: " + this.ExternalDirectoryObjectId
                        }
                    });
                }
            }
            else
            {
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: SharePoint is not enabled, skipping notification about group creation", base.ActivityId);
            }
            this.CreationDiagnostics.RecordSharePointNotificationTime();
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.ExchangeCreate;
            UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Creating group in Exchange", base.ActivityId);
            GroupMailbox groupMailbox = this.CreateGroupMailbox(this.ExternalDirectoryObjectId);

            this.ADObjectGuid = groupMailbox.Guid;
            this.SmtpAddress  = groupMailbox.PrimarySmtpAddress.ToString();
            UnifiedGroupsTask.Tracer.TraceDebug <Guid, ObjectId>((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.Run: Finished creating group in Exchange. Identity: {1}", base.ActivityId, groupMailbox.Identity);
            this.CreationDiagnostics.RecordMailboxTime();
            this.CreationDiagnostics.MailboxCreatedSuccessfully = true;
            string text = this.EnsureGroupIsInDirectoryCache(groupMailbox);

            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("Created group. Name: {0}, Alias: {1}, Type: {2}, ExternalDirectoryObjectId: {3}, By: {4}. EnsureCached={5}", new object[]
                    {
                        this.Name,
                        this.Alias,
                        this.Type,
                        this.ExternalDirectoryObjectId,
                        this.accessingPrincipal.MailboxInfo.PrimarySmtpAddress,
                        text
                    })
                }
            });
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.Completed;
            this.CreationDiagnostics.Stop();
        }
示例#8
0
        private bool RunWithLogging()
        {
            Exception ex = null;

            try
            {
                this.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.None;
                this.RunInternal();
            }
            catch (AADDataException ex2)
            {
                this.ErrorCode = ex2.Code.ToString();
                ex             = ex2;
            }
            catch (LocalizedException ex3)
            {
                ex = ex3;
            }
            catch (WebException ex4)
            {
                ex = ex4;
            }
            catch (ClientRequestException ex5)
            {
                ex = ex5;
            }
            catch (ServerException ex6)
            {
                ex = ex6;
            }
            if (ex != null)
            {
                UnifiedGroupsTask.Tracer.TraceError <UnifiedGroupsTask.UnifiedGroupsAction, Exception>((long)this.GetHashCode(), "UnifiedGroupsTask.RunWithLogging: RunInternal threw an exception. CurrentAction: {0}, exception: {1}", this.CurrentAction, ex);
                FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.ExceptionTag>
                {
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.TaskName,
                        this.TaskName
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ActivityId,
                        this.ActivityId
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ExceptionType,
                        ex.GetType()
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ExceptionDetail,
                        ex
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.CurrentAction,
                        this.CurrentAction
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.Message,
                        "RunInternal threw an exception"
                    }
                });
                this.ErrorAction    = this.CurrentAction;
                this.ErrorException = ex;
                return(false);
            }
            return(true);
        }
示例#9
0
        private void TryNotifySharePointForExchangeResources(MailboxUrls mailboxUrls)
        {
            OrganizationId orgId = this.groupADUser.OrganizationId;
            string         externalDirectoryObjectId = this.groupADUser.ExternalDirectoryObjectId;
            Guid           activityId = this.activityId;
            Stopwatch      timer      = Stopwatch.StartNew();

            Task.Factory.StartNew(delegate()
            {
                ICredentials oauthCredentialsForAppToken = OAuthCredentials.GetOAuthCredentialsForAppToken(orgId, "dummyRealm");
                using (SharePointNotification sharePointNotification = new SharePointNotification(SharePointNotification.NotificationType.Update, externalDirectoryObjectId, orgId, oauthCredentialsForAppToken, activityId))
                {
                    foreach (KeyValuePair <string, string> keyValuePair in mailboxUrls.ToExchangeResourcesDictionary())
                    {
                        sharePointNotification.SetResourceValue(keyValuePair.Key, keyValuePair.Value, false);
                    }
                    sharePointNotification.Execute();
                    string value = string.Format("Success;Group={0};Org={1};ElapsedTime={2}", externalDirectoryObjectId, orgId, timer.ElapsedMilliseconds);
                    FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
                    {
                        {
                            FederatedDirectoryLogSchema.TraceTag.TaskName,
                            "UpdateSiteCollectionTask"
                        },
                        {
                            FederatedDirectoryLogSchema.TraceTag.ActivityId,
                            activityId
                        },
                        {
                            FederatedDirectoryLogSchema.TraceTag.CurrentAction,
                            "SharePointSetMailboxUrls"
                        },
                        {
                            FederatedDirectoryLogSchema.TraceTag.Message,
                            value
                        }
                    });
                }
            }).ContinueWith(delegate(Task t)
            {
                Exception ex = null;
                if (t.Exception != null)
                {
                    ex = t.Exception.InnerException;
                }
                string value = string.Format("Failed;Group={0};Org={1};ElapsedTime={2}", externalDirectoryObjectId, orgId, timer.ElapsedMilliseconds);
                FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.ExceptionTag>
                {
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.TaskName,
                        "UpdateSiteCollectionTask"
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ActivityId,
                        activityId
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.CurrentAction,
                        "SharePointSetMailboxUrls"
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ExceptionType,
                        (ex != null) ? ex.GetType().ToString() : "Unknown"
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.ExceptionDetail,
                        ex
                    },
                    {
                        FederatedDirectoryLogSchema.ExceptionTag.Message,
                        value
                    }
                });
            }, TaskContinuationOptions.OnlyOnFaulted);
        }
示例#10
0
        public bool Publish(int?publishedVersion)
        {
            if (!GroupMailboxExchangeResourcesPublisher.IsPublishedVersionOutdated(publishedVersion))
            {
                return(true);
            }
            MailboxUrls mailboxUrls = new MailboxUrls(ExchangePrincipal.FromADUser(this.groupADUser, null), true);
            AADClient   aadclient   = AADClientFactory.Create(this.groupADUser.OrganizationId, GraphProxyVersions.Version14);

            if (aadclient == null)
            {
                string value = string.Format("AADClient was null for organization {0} and group {1}", this.groupADUser.OrganizationId, this.groupADUser.ExternalDirectoryObjectId);
                throw new LocalizedException(new LocalizedString(value));
            }
            if (publishedVersion == null)
            {
                Group group = aadclient.GetGroup(this.groupADUser.ExternalDirectoryObjectId, false);
                if (group == null)
                {
                    FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag>
                    {
                        {
                            FederatedDirectoryLogSchema.TraceTag.TaskName,
                            "PublishResourcesToAAD"
                        },
                        {
                            FederatedDirectoryLogSchema.TraceTag.ActivityId,
                            this.activityId
                        },
                        {
                            FederatedDirectoryLogSchema.TraceTag.CurrentAction,
                            "GetGroupFromAAD"
                        },
                        {
                            FederatedDirectoryLogSchema.TraceTag.Message,
                            string.Format("Unable to find group in AAD. ExternalId={0}", this.groupADUser.ExternalDirectoryObjectId)
                        }
                    });
                    return(false);
                }
                string[] array;
                if (group.exchangeResources == null)
                {
                    array = new string[0];
                }
                else
                {
                    array = (from s in @group.exchangeResources
                             select s.ToLower()).ToArray <string>();
                }
                string[] array2 = array;
                string[] array3 = (from s in mailboxUrls.ToExchangeResources()
                                   select s.ToLower()).ToArray <string>();
                if (array2.Length == array3.Length && array2.Except(array3).Count <string>() == 0)
                {
                    return(true);
                }
            }
            string[] exchangeResources = mailboxUrls.ToExchangeResources();
            aadclient.UpdateGroup(this.groupADUser.ExternalDirectoryObjectId, null, exchangeResources, null, null);
            this.TryNotifySharePointForExchangeResources(mailboxUrls);
            return(true);
        }
示例#11
0
        protected override void RunInternal()
        {
            UnifiedGroupsTask.Tracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: User {1} is deleting group {2}", base.ActivityId, this.accessingPrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), this.ExternalDirectoryObjectId ?? this.SmtpAddress);
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.AADDelete;
            try
            {
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: Deleting group in AAD", base.ActivityId);
                this.DeleteAAD();
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: Finished deleting group in AAD", base.ActivityId);
            }
            catch (AADDataException ex)
            {
                if (ex.Code != AADDataException.AADCode.Request_ResourceNotFound)
                {
                    throw;
                }
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: Group not found in AAD", base.ActivityId);
            }
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.SharePointDelete;
            if (base.IsSharePointEnabled)
            {
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: Enqueuing job to notify SharePoint about group deletion", base.ActivityId);
                DeleteSiteCollectionTask task = new DeleteSiteCollectionTask(base.AccessingUser, base.ADSession, base.ActivityId)
                {
                    ExternalDirectoryObjectId = this.ExternalDirectoryObjectId,
                    SmtpAddress = this.SmtpAddress
                };
                bool flag = UnifiedGroupsTask.QueueTask(task);
                UnifiedGroupsTask.Tracer.TraceDebug <Guid, bool>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: Finished enqueuing job to notify SharePoint about group deletion. queued: {1}", base.ActivityId, flag);
                if (!flag)
                {
                    UnifiedGroupsTask.Tracer.TraceError <Guid>((long)this.GetHashCode(), "ActivityId={0}. Failed to queue job to notify SharePoint about group deletion", 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 deletion. ExternalDirectoryObjectId: " + this.ExternalDirectoryObjectId
                        }
                    });
                }
            }
            else
            {
                UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: SharePoint is not enabled, skipping notification about group creation", base.ActivityId);
            }
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.ExchangeDelete;
            UnifiedGroupsTask.Tracer.TraceDebug <Guid>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: Enqueuing job to delete group in Exchange", base.ActivityId);
            bool flag2 = UnifiedGroupsTask.QueueTask(new DeleteGroupMailboxTask(base.AccessingUser, this.accessingPrincipal, base.ADSession)
            {
                ExternalDirectoryObjectId = this.ExternalDirectoryObjectId,
                SmtpAddress = this.SmtpAddress
            });

            UnifiedGroupsTask.Tracer.TraceDebug <Guid, bool>((long)this.GetHashCode(), "ActivityId={0}. DeleteUnifiedGroupTask.Run: Finished enqueuing job to delete group in Exchange. queued: {1}", base.ActivityId, flag2);
            if (!flag2)
            {
                UnifiedGroupsTask.Tracer.TraceError <Guid>((long)this.GetHashCode(), "ActivityId={0}. Failed to queue job to delete 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("Failed to queue job to delete group in Exchange. ExternalDirectoryObjectId: {0}", this.ExternalDirectoryObjectId)
                    }
                });
            }
            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("Deleted group. ExternalDirectoryObjectId: {0}, By: {1}", this.ExternalDirectoryObjectId ?? this.SmtpAddress, this.accessingPrincipal.MailboxInfo.PrimarySmtpAddress.ToString())
                }
            });
            base.CurrentAction = UnifiedGroupsTask.UnifiedGroupsAction.Completed;
        }