private void UpdateSiteCollection() { using (SharePointNotification sharePointNotification = new SharePointNotification(SharePointNotification.NotificationType.Update, this.ExternalDirectoryObjectId, base.AccessingUser.OrganizationId, base.ActAsUserCredentials, base.ActivityId)) { if (this.Description != null) { sharePointNotification.SetPropertyValue("Description", this.Description, false); } if (!string.IsNullOrEmpty(this.DisplayName)) { sharePointNotification.SetPropertyValue("DisplayName", this.DisplayName, false); } if (this.AddedOwners != null && this.AddedOwners.Length != 0) { sharePointNotification.AddOwners(this.AddedOwners); } if (this.RemovedOwners != null && this.RemovedOwners.Length != 0) { sharePointNotification.RemoveOwners(this.RemovedOwners); } if (this.AddedMembers != null && this.AddedMembers.Length != 0) { sharePointNotification.AddMembers(this.AddedMembers); } if (this.RemovedMembers != null && this.RemovedMembers.Length != 0) { sharePointNotification.RemoveMembers(this.RemovedMembers); } sharePointNotification.Execute(); } }
private void CreateSiteCollection() { using (SharePointNotification sharePointNotification = new SharePointNotification(SharePointNotification.NotificationType.Create, this.ExternalDirectoryObjectId, base.AccessingUser.OrganizationId, base.ActAsUserCredentials, base.ActivityId)) { sharePointNotification.SetPropertyValue("Alias", this.Alias, false); sharePointNotification.SetPropertyValue("DisplayName", this.Name, false); sharePointNotification.SetPropertyValue("IsPublic", this.Type == ModernGroupTypeInfo.Public, false); if (!string.IsNullOrEmpty(this.Description)) { sharePointNotification.SetPropertyValue("Description", this.Description, false); } sharePointNotification.SetAllowAccessTo(this.Type == ModernGroupTypeInfo.Public); sharePointNotification.Execute(); } }
private void DeleteSiteCollection() { if (string.IsNullOrEmpty(this.ExternalDirectoryObjectId)) { ObjectIdMapping objectIdMapping = new ObjectIdMapping(base.ADSession); objectIdMapping.Prefetch(new string[] { this.SmtpAddress }); this.ExternalDirectoryObjectId = objectIdMapping.GetIdentityFromSmtpAddress(this.SmtpAddress); } using (SharePointNotification sharePointNotification = new SharePointNotification(SharePointNotification.NotificationType.Delete, this.ExternalDirectoryObjectId, base.AccessingUser.OrganizationId, base.ActAsUserCredentials, base.ActivityId)) { sharePointNotification.Execute(); } }
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); }