protected override void InternalSave(ConfigurableObject instance) { if (instance == null) { throw new ArgumentNullException("instance"); } MailboxCalendarFolder mailboxCalendarFolder = instance as MailboxCalendarFolder; if (mailboxCalendarFolder == null) { throw new NotSupportedException("Save: " + instance.GetType().FullName); } if (mailboxCalendarFolder.PublishEnabled) { SharingPolicy sharingPolicy = DirectoryHelper.ReadSharingPolicy(base.MailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, base.MailboxSession.MailboxOwner.MailboxInfo.IsArchive, base.MailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); if (sharingPolicy == null || !sharingPolicy.Enabled || !sharingPolicy.IsAllowedForAnonymousCalendarSharing()) { throw new NotAllowedPublishingByPolicyException(); } SharingPolicyAction allowedForAnonymousCalendarSharing = sharingPolicy.GetAllowedForAnonymousCalendarSharing(); int maxAllowed = PolicyAllowedDetailLevel.GetMaxAllowed(allowedForAnonymousCalendarSharing); if (mailboxCalendarFolder.DetailLevel > (DetailLevelEnumType)maxAllowed) { throw new NotAllowedPublishingByPolicyException(mailboxCalendarFolder.DetailLevel, (DetailLevelEnumType)maxAllowed); } } MailboxFolderId mailboxFolderId = mailboxCalendarFolder.MailboxFolderId; StoreObjectId folderId = mailboxFolderId.StoreObjectIdValue ?? base.ResolveStoreObjectIdFromFolderPath(mailboxFolderId.MailboxFolderPath); if (folderId == null || folderId.ObjectType != StoreObjectType.CalendarFolder) { throw new CantFindCalendarFolderException(mailboxFolderId); } using (CalendarFolder calendarFolder = CalendarFolder.Bind(base.MailboxSession, folderId)) { ExtendedFolderFlags?valueAsNullable = calendarFolder.GetValueAsNullable <ExtendedFolderFlags>(FolderSchema.ExtendedFolderFlags); if (valueAsNullable != null && (valueAsNullable.Value & ExtendedFolderFlags.PersonalShare) != (ExtendedFolderFlags)0) { throw new CannotShareFolderException(ServerStrings.CannotShareOtherPersonalFolder); } this.SaveSharingAnonymous(mailboxCalendarFolder, folderId); if (!mailboxCalendarFolder.PublishEnabled) { mailboxCalendarFolder.PublishedCalendarUrl = null; mailboxCalendarFolder.PublishedICalUrl = null; } UserConfigurationDictionaryHelper.Save(mailboxCalendarFolder, MailboxCalendarFolder.CalendarFolderConfigurationProperties, (bool createIfNonexisting) => UserConfigurationHelper.GetPublishingConfiguration(this.MailboxSession, folderId, createIfNonexisting)); if (MailboxCalendarFolderDataProvider.UpdateExtendedFolderFlags(mailboxCalendarFolder, calendarFolder)) { calendarFolder.Save(); } } }
private void ExecuteCalendarVDirTests(TestCasConnectivity.TestCasConnectivityRunInstance instance, CasTransactionOutcome outcome) { string text = string.Format("{0}/Calendar/calendar.html", instance.exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()); string text2 = string.Format("{0}/Calendar/calendar.ics", instance.exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()); ADSessionSettings adsessionSettings = instance.exchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings(); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, adsessionSettings, 293, "ExecuteCalendarVDirTests", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Monitoring\\Tasks\\TestCalendarConnectivity.cs"); using (MailboxCalendarFolderDataProvider mailboxCalendarFolderDataProvider = new MailboxCalendarFolderDataProvider(adsessionSettings, DirectoryHelper.ReadADRecipient(instance.exchangePrincipal.MailboxInfo.MailboxGuid, instance.exchangePrincipal.MailboxInfo.IsArchive, tenantOrRootOrgRecipientSession) as ADUser, "Test-CalendarConnectivity")) { StoreObjectId defaultFolderId = mailboxCalendarFolderDataProvider.MailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar); Microsoft.Exchange.Data.Storage.Management.MailboxFolderId identity = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(instance.exchangePrincipal.ObjectId, defaultFolderId, null); MailboxCalendarFolder mailboxCalendarFolder = (MailboxCalendarFolder)mailboxCalendarFolderDataProvider.Read <MailboxCalendarFolder>(identity); if (!mailboxCalendarFolder.PublishEnabled) { mailboxCalendarFolder.SearchableUrlEnabled = true; mailboxCalendarFolder.PublishEnabled = true; mailboxCalendarFolder.PublishedCalendarUrl = new Uri(instance.baseUri, text).ToString(); mailboxCalendarFolder.PublishedICalUrl = new Uri(instance.baseUri, text2).ToString(); try { mailboxCalendarFolderDataProvider.Save(mailboxCalendarFolder); } catch (NotAllowedPublishingByPolicyException ex) { instance.Outcomes.Enqueue(new Warning(ex.LocalizedString)); return; } } } ADOwaVirtualDirectory adowaVirtualDirectory = instance.VirtualDirectory as ADOwaVirtualDirectory; if (adowaVirtualDirectory != null && !(adowaVirtualDirectory.AnonymousFeaturesEnabled != true)) { base.WriteMonitoringEvent(1104, this.MonitoringEventSource, EventTypeEnumeration.Success, Strings.CasHealthCalendarVDirSuccess); TimeSpan latency; if (!this.TestCalendarUrlResponse(text2, instance, TestCalendarConnectivity.CalendarContext.ICalContext, out latency)) { outcome.Update(CasTransactionResultEnum.Failure); } else { outcome.UpdateLatency(latency); } if (!this.TestCalendarUrlResponse(text, instance, TestCalendarConnectivity.CalendarContext.ViewCalendarContext, out latency)) { outcome.Update(CasTransactionResultEnum.Failure); } return; } instance.Outcomes.Enqueue(new Warning(Strings.CasHealthCalendarVDirWarning(instance.VirtualDirectoryName, instance.CasFqdn))); outcome.Update(CasTransactionResultEnum.Skipped); base.WriteMonitoringEvent(1105, this.MonitoringEventSource, EventTypeEnumeration.Warning, Strings.CasHealthCalendarVDirWarning(instance.VirtualDirectoryName, instance.CasFqdn)); }
public static Identity ToIdentity(this MailboxFolder entry) { string name = entry.Name; if (entry.DefaultFolderType == DefaultFolderType.Root) { Microsoft.Exchange.Data.Storage.Management.MailboxFolderId mailboxFolderId = (Microsoft.Exchange.Data.Storage.Management.MailboxFolderId)entry.Identity; if (ADObjectId.Equals(mailboxFolderId.MailboxOwnerId, EacRbacPrincipal.Instance.ExecutingUserId)) { name = EacRbacPrincipal.Instance.Name; } else { name = mailboxFolderId.MailboxOwnerId.Name; } } return(new Identity(entry.FolderStoreObjectId, name)); }
protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) { if (sortBy != null) { throw new NotSupportedException("sortBy"); } if (rootId == null) { throw new NotSupportedException("rootId must be specified"); } if (!(rootId is MailboxFolderId)) { throw new NotSupportedException("rootId: " + rootId.GetType().FullName); } if (!typeof(MailboxCalendarFolder).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo())) { throw new NotSupportedException("FindPaged: " + typeof(T).FullName); } MailboxFolderId mailboxFolderId = (MailboxFolderId)rootId; StoreObjectId folderId = mailboxFolderId.StoreObjectIdValue ?? base.ResolveStoreObjectIdFromFolderPath(mailboxFolderId.MailboxFolderPath); if (folderId == null) { throw new CantFindCalendarFolderException(mailboxFolderId); } using (Folder folder = Folder.Bind(base.MailboxSession, folderId)) { if (!StringComparer.OrdinalIgnoreCase.Equals(folder.ClassName, "IPF.Appointment")) { throw new CantFindCalendarFolderException(mailboxFolderId); } } MailboxCalendarFolder mailboxCalendarFolder = (MailboxCalendarFolder)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); mailboxCalendarFolder.MailboxFolderId = mailboxFolderId; UserConfigurationDictionaryHelper.Fill(mailboxCalendarFolder, MailboxCalendarFolder.CalendarFolderConfigurationProperties, (bool createIfNonexisting) => UserConfigurationHelper.GetPublishingConfiguration(this.MailboxSession, folderId, createIfNonexisting)); yield return((T)((object)mailboxCalendarFolder)); yield break; }
public override bool Equals(XsoMailboxObjectId other) { MailboxFolderId mailboxFolderId = other as MailboxFolderId; if (null == mailboxFolderId) { return(false); } if (!ADObjectId.Equals(base.MailboxOwnerId, other.MailboxOwnerId)) { return(false); } bool flag = object.Equals(this.StoreObjectIdValue, mailboxFolderId.StoreObjectIdValue); if (flag && this.StoreObjectIdValue != null) { return(true); } bool flag2 = object.Equals(this.MailboxFolderPath, mailboxFolderId.MailboxFolderPath); return((flag2 && null != this.MailboxFolderPath) || (flag2 && flag)); }
protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) { if (sortBy != null) { throw new NotSupportedException("sortBy"); } if (rootId != null && !(rootId is MailboxFolderId)) { throw new NotSupportedException("rootId: " + rootId.GetType().FullName); } if (!typeof(MailboxFolder).GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo())) { throw new NotSupportedException("FindPaged: " + typeof(T).FullName); } if (filter == null) { filter = MailboxFolderDataProvider.nonHiddenFilter; } else { filter = new AndFilter(new QueryFilter[] { filter, MailboxFolderDataProvider.nonHiddenFilter }); } Dictionary <StoreObjectId, MapiFolderPath> knownFolderPathsCache = new Dictionary <StoreObjectId, MapiFolderPath>(); knownFolderPathsCache.Add(base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root), MapiFolderPath.IpmSubtreeRoot); knownFolderPathsCache.Add(base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration), MapiFolderPath.NonIpmSubtreeRoot); StoreObjectId xsoRootIdentity; MapiFolderPath xsoRootFolderPath; if (rootId == null) { xsoRootIdentity = base.MailboxSession.SafeGetDefaultFolderId(DefaultFolderType.Root); xsoRootFolderPath = MapiFolderPath.IpmSubtreeRoot; } else { MailboxFolderId mailboxFolderId = (MailboxFolderId)rootId; if (mailboxFolderId.StoreObjectIdValue == null) { StoreObjectId storeObjectId = base.ResolveStoreObjectIdFromFolderPath(mailboxFolderId.MailboxFolderPath); if (storeObjectId == null) { yield break; } xsoRootIdentity = storeObjectId; } else { xsoRootIdentity = mailboxFolderId.StoreObjectIdValue; } xsoRootFolderPath = mailboxFolderId.MailboxFolderPath; } MailboxFolder rootFolder = (MailboxFolder)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); PropertyDefinition[] xsoProperties = rootFolder.Schema.AllDependentXsoProperties; Folder xsoFolder = Folder.Bind(base.MailboxSession, xsoRootIdentity, xsoProperties); rootFolder.LoadDataFromXso(base.MailboxSession.MailboxOwner.ObjectId, xsoFolder); rootFolder.SetDefaultFolderType(base.MailboxSession.IsDefaultFolderType(xsoRootIdentity)); if (null == xsoRootFolderPath) { xsoRootFolderPath = MailboxFolderDataProvider.CalculateMailboxFolderPath(base.MailboxSession, rootFolder.InternalFolderIdentity.ObjectId, rootFolder.InternalParentFolderIdentity, rootFolder.Name, knownFolderPathsCache); } else if (!knownFolderPathsCache.ContainsKey(rootFolder.InternalFolderIdentity.ObjectId)) { knownFolderPathsCache.Add(rootFolder.InternalFolderIdentity.ObjectId, xsoRootFolderPath); } rootFolder.FolderPath = xsoRootFolderPath; if (deepSearch) { yield return((T)((object)rootFolder)); } QueryResult queryResults = xsoFolder.FolderQuery(deepSearch ? FolderQueryFlags.DeepTraversal : FolderQueryFlags.None, filter, null, new PropertyDefinition[] { FolderSchema.Id }); for (;;) { object[][] folderRows = queryResults.GetRows((pageSize == 0) ? 1000 : pageSize); if (folderRows.Length <= 0) { break; } foreach (object[] row in folderRows) { MailboxFolder oneFolder = (MailboxFolder)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); using (Folder oneXsoFolder = Folder.Bind(base.MailboxSession, ((VersionedId)row[0]).ObjectId, xsoProperties)) { oneFolder.LoadDataFromXso(base.MailboxSession.MailboxOwner.ObjectId, oneXsoFolder); oneFolder.SetDefaultFolderType(base.MailboxSession.IsDefaultFolderType(oneFolder.InternalFolderIdentity)); oneFolder.FolderPath = MailboxFolderDataProvider.CalculateMailboxFolderPath(base.MailboxSession, oneFolder.InternalFolderIdentity.ObjectId, oneFolder.InternalParentFolderIdentity, oneFolder.Name, knownFolderPathsCache); yield return((T)((object)oneFolder)); } } } yield break; }