Пример #1
0
        private Guid GetHierarchyMailboxGuidForUser()
        {
            Guid result;

            using (this.CheckDisposed("GetHierarchyMailboxGuidForUser"))
            {
                ExTraceGlobals.SessionTracer.TraceDebug((long)this.GetHashCode(), "PublicFolderSessionCache.GetHierarchyMailboxGuidForUser called");
                Guid empty = Guid.Empty;
                bool flag;
                if (this.openSessionAsAdmin)
                {
                    flag = PublicFolderSession.TryGetPrimaryHierarchyMailboxGuid(this.organizationId, out empty);
                }
                else
                {
                    flag = PublicFolderSession.TryGetHierarchyMailboxGuidForUser(this.organizationId, this.connectAsPrincipal.MailboxInfo.MailboxGuid, this.connectAsPrincipal.DefaultPublicFolderMailbox, out empty);
                }
                if (!flag)
                {
                    throw new ObjectNotFoundException(PublicFolderSession.GetNoPublicFoldersProvisionedError(this.organizationId));
                }
                result = empty;
            }
            return(result);
        }
Пример #2
0
 internal static MailboxFolderIdParameter GetMailboxFolderIdParameterForPublicFolder(IConfigurationSession configurationSession, PublicFolderIdParameter publicFolderIdParameter, Guid publicFolderMailboxGuid, ADUser publicFolderMailboxUser, OrganizationId organizationId, Task.ErrorLoggerDelegate errorHandler)
 {
     if (publicFolderMailboxUser == null)
     {
         publicFolderMailboxUser = PublicFolderPermissionTaskHelper.GetPublicFolderHierarchyMailboxUser(configurationSession);
         if (publicFolderMailboxUser == null)
         {
             errorHandler(new LocalizedException(PublicFolderSession.GetNoPublicFoldersProvisionedError(configurationSession.SessionSettings.CurrentOrganizationId)), ExchangeErrorCategory.Client, publicFolderIdParameter);
         }
     }
     if (publicFolderIdParameter.PublicFolderId.StoreObjectId == null)
     {
         using (PublicFolderDataProvider publicFolderDataProvider = new PublicFolderDataProvider(configurationSession, "*-PublicFolderClientPermission", publicFolderMailboxGuid))
         {
             StoreObjectId storeObjectId = publicFolderDataProvider.ResolveStoreObjectIdFromFolderPath(publicFolderIdParameter.PublicFolderId.MapiFolderPath);
             if (storeObjectId == null)
             {
                 errorHandler(new LocalizedException(Strings.ErrorPublicFolderNotFound(publicFolderIdParameter.ToString())), ExchangeErrorCategory.Client, publicFolderIdParameter);
             }
             publicFolderIdParameter.PublicFolderId.StoreObjectId = storeObjectId;
         }
     }
     if (publicFolderIdParameter.Organization != null)
     {
         publicFolderIdParameter.PublicFolderId.OrganizationId = organizationId;
     }
     return(new MailboxFolderIdParameter(publicFolderIdParameter, publicFolderMailboxUser));
 }
        private void OnBeforeCreateFolder(Folder parentFolder)
        {
            PublicFolderSession publicFolderSession = base.Session as PublicFolderSession;

            if (publicFolderSession == null)
            {
                return;
            }
            if (this.isSearchFolder)
            {
                base.SetProperty(CoreFolderSchema.ReplicaList, new string[]
                {
                    publicFolderSession.MailboxGuid.ToString()
                });
                return;
            }
            PublicFolderContentMailboxInfo contentMailboxInfo  = CoreFolder.GetContentMailboxInfo(base.GetValueOrDefault <string[]>(CoreFolderSchema.ReplicaList, Array <string> .Empty));
            PublicFolderContentMailboxInfo contentMailboxInfo2 = parentFolder.GetContentMailboxInfo();
            Guid guid = contentMailboxInfo.IsValid ? contentMailboxInfo.MailboxGuid : (contentMailboxInfo2.IsValid ? contentMailboxInfo2.MailboxGuid : publicFolderSession.MailboxGuid);

            base.SetProperty(CoreFolderSchema.ReplicaList, new string[]
            {
                guid.ToString()
            });
        }
        private ISourceMailbox GetSourceMailbox()
        {
            ISourceMailbox result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                ExchangePrincipal exchangePrincipal;
                if (!PublicFolderSession.TryGetPublicFolderMailboxPrincipal(this.OrganizationId, PublicFolderSession.HierarchyMailboxGuidAlias, true, out exchangePrincipal))
                {
                    throw new StoragePermanentException(PublicFolderSession.GetNoPublicFoldersProvisionedError(this.OrganizationId));
                }
                ISourceMailbox sourceMailbox = new RemoteSourceMailbox(exchangePrincipal.MailboxInfo.Location.ServerFqdn, null, null, this.isSingleFolderSync ? ProxyControlFlags.SkipWLMThrottling : ProxyControlFlags.None, PublicFolderSynchronizerContext.RequiredCapabilities, false, LocalMailboxFlags.None);
                disposeGuard.Add <ISourceMailbox>(sourceMailbox);
                TenantPartitionHint partitionHint = CommonUtils.GetPartitionHint(this.OrganizationId);
                if (this.Logger != null)
                {
                    this.Logger.LogEvent(LogEventType.Verbose, string.Format("Connecting to Primary Hierarchy. [Mailbox:{0}; Server:{1}; Database:{2}; PartitionHint:{3}]", new object[]
                    {
                        exchangePrincipal.MailboxInfo.MailboxGuid,
                        exchangePrincipal.MailboxInfo.Location.ServerFqdn,
                        exchangePrincipal.MailboxInfo.GetDatabaseGuid(),
                        partitionHint
                    }));
                }
                sourceMailbox.Config(null, exchangePrincipal.MailboxInfo.MailboxGuid, exchangePrincipal.MailboxInfo.MailboxGuid, partitionHint, exchangePrincipal.MailboxInfo.GetDatabaseGuid(), MailboxType.SourceMailbox, null);
                sourceMailbox.Connect(MailboxConnectFlags.PublicFolderHierarchyReplication);
                disposeGuard.Success();
                result = sourceMailbox;
            }
            return(result);
        }
Пример #5
0
        // Token: 0x06000F19 RID: 3865 RVA: 0x0005A248 File Offset: 0x00058448
        public static void SyncAndWaitForCompletion(Guid mailboxGuid, OrganizationId organizationId, IXSOFactory xsoFactory, IPublicFolderMailboxLoggerBase logger, ISplitOperationState splitOperationState)
        {
            ExchangePrincipal contentMailboxPrincipal;

            if (!PublicFolderSession.TryGetPublicFolderMailboxPrincipal(organizationId, mailboxGuid, false, out contentMailboxPrincipal))
            {
                throw new ObjectNotFoundException(ServerStrings.PublicFolderMailboxNotFound);
            }
            PublicFolderSyncJobState publicFolderSyncJobState = PublicFolderSyncJobRpc.StartSyncHierarchy(contentMailboxPrincipal, true);
            int num = 0;

            while (publicFolderSyncJobState.JobStatus != PublicFolderSyncJobState.Status.Completed && publicFolderSyncJobState.LastError == null && (double)num++ < PublicFolderSplitConfig.Instance.TimeoutForSynchronousOperation.TotalMilliseconds / PublicFolderSplitConfig.Instance.QuerySyncStatusInterval.TotalMilliseconds)
            {
                Thread.Sleep(PublicFolderSplitConfig.Instance.QuerySyncStatusInterval.Milliseconds);
                publicFolderSyncJobState = PublicFolderSyncJobRpc.QueryStatusSyncHierarchy(contentMailboxPrincipal);
            }
            bool flag;

            if (publicFolderSyncJobState.JobStatus != PublicFolderSyncJobState.Status.Completed || PublicFolderSplitHelper.IsSyncRequired(mailboxGuid, organizationId, out flag, xsoFactory, logger))
            {
                splitOperationState.Error = new SyncInProgressException(organizationId.OrganizationalUnit.Name, mailboxGuid.ToString());
                return;
            }
            if (PublicFolderSplitHelper.HasSyncFailure(publicFolderSyncJobState))
            {
                splitOperationState.Error = publicFolderSyncJobState.LastError;
            }
        }
        private bool IsExternalFreeBusyFolderCreated(string legacyDN, PublicFolderDatabase publicFolderDatabase)
        {
            Server server = publicFolderDatabase.GetServer();

            if (server == null)
            {
                return(false);
            }
            bool result;

            try
            {
                using (PublicFolderSession publicFolderSession = this.GetPublicFolderSession(server))
                {
                    StoreObjectId freeBusyFolderId = FreeBusyFolder.GetFreeBusyFolderId(publicFolderSession, legacyDN, FreeBusyFolderDisposition.None);
                    result = (freeBusyFolderId != null);
                }
            }
            catch (LocalizedException)
            {
                base.WriteVerbose(Strings.InstallFreeBusyFolderUnableToCheckDatabase(publicFolderDatabase.Id.ToString()));
                result = false;
            }
            return(result);
        }
Пример #7
0
        private bool ShouldSyncMailbox()
        {
            bool result;

            try
            {
                ExchangePrincipal exchangePrincipal;
                if (!PublicFolderSession.TryGetPublicFolderMailboxPrincipal(this.OrganizationId, this.ContentMailboxGuid, false, out exchangePrincipal) || exchangePrincipal == null)
                {
                    PublicFolderSynchronizerLogger.LogOnServer(string.Format("Sync Cancelled for Mailbox {0} in Organization {1}. Could not get ExchangePrincipal. Mailbox could have been deleted.", this.ContentMailboxGuid, this.OrganizationId), LogEventType.Warning, null);
                    result = false;
                }
                else if (!exchangePrincipal.MailboxInfo.IsRemote && LocalServerCache.LocalServer != null && exchangePrincipal.MailboxInfo.Location.ServerFqdn != LocalServerCache.LocalServer.Fqdn)
                {
                    PublicFolderSynchronizerLogger.LogOnServer(string.Format("Sync Cancelled for Mailbox {0} in Organization {1}. Mailbox was moved to Server {2}.", this.ContentMailboxGuid, this.OrganizationId, exchangePrincipal.MailboxInfo.Location.ServerFqdn), LogEventType.Warning, null);
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            catch (LocalizedException e)
            {
                PublicFolderSynchronizerLogger.LogOnServer(string.Format("Sync Cancelled for Mailbox {0} in Organization {1}. Could not get ExchangePrincipal. Mailbox could have been deleted/relocated. Exception - {2}", this.ContentMailboxGuid, this.OrganizationId, PublicFolderMailboxLoggerBase.GetExceptionLogString(e, PublicFolderMailboxLoggerBase.ExceptionLogOption.All)), LogEventType.Warning, null);
                result = false;
            }
            return(result);
        }
        internal static PublicFolderMailboxDiagnosticsInfo Load(OrganizationId organizationId, Guid contentMailboxGuid, DiagnosticsLoadFlags loadFlags, Action <LocalizedString, LocalizedString, int> writeProgress)
        {
            PublicFolderMailboxDiagnosticsInfo result;

            using (PublicFolderSession publicFolderSession = PublicFolderSession.OpenAsAdmin(organizationId, null, contentMailboxGuid, null, CultureInfo.CurrentCulture, "Client=Management;Action=Get-PublicFolderMailboxDiagnostics", null))
            {
                result = PublicFolderMailboxDiagnosticsInfo.Load(publicFolderSession, loadFlags, writeProgress);
            }
            return(result);
        }
Пример #9
0
        // Token: 0x06000F18 RID: 3864 RVA: 0x0005A21C File Offset: 0x0005841C
        public static bool IsPrimaryHierarchy(Guid mailboxGuid, OrganizationId organizationId)
        {
            Guid g;

            if (PublicFolderSession.TryGetPrimaryHierarchyMailboxGuid(organizationId, out g))
            {
                return(mailboxGuid.Equals(g));
            }
            throw new ObjectNotFoundException(PublicFolderSession.GetNoPublicFoldersProvisionedError(organizationId));
        }
Пример #10
0
        private PublicFolderSession GetPublicFolderSession()
        {
            PublicFolderSession publicFolderSession = this.StoreSession as PublicFolderSession;

            if (publicFolderSession == null)
            {
                throw new StorageConnectionTypeException((this.StoreSession == null) ? "null" : this.StoreSession.GetType().ToString());
            }
            return(publicFolderSession);
        }
Пример #11
0
        public void CreatePublicFolderMessage(MailRecipient recipient, DeliverableItem item)
        {
            PublicFolderSession publicFolderSession = (PublicFolderSession)this.storeSession;
            bool flag = false;

            try
            {
                this.context.BeginTrackLatency(LatencyComponent.StoreDriverDeliveryRpc);
                using (Folder folder = Folder.Bind(publicFolderSession, this.deliverToFolder, new PropertyDefinition[]
                {
                    FolderSchema.SecurityDescriptor
                }))
                {
                    switch (MailPublicFolderPermissionHandler.CheckAccessForEmailDelivery(this.context, folder))
                    {
                    case AccessCheckResult.NotAllowedAnonymous:
                        DeliveryItem.Diag.TraceError(0L, "Anonymous users are not permitted to add contents to mail enabled public folder.");
                        throw new SmtpResponseException(AckReason.NotAuthenticated, MessageAction.NDR);

                    case AccessCheckResult.NotAllowedAuthenticated:
                        DeliveryItem.Diag.TraceError <RoutingAddress>(0L, "User {0} is not permitted to add contents to mail enabled public folder.", this.context.MbxTransportMailItem.From);
                        throw new SmtpResponseException(AckReason.RecipientPermissionRestricted, MessageAction.NDR);

                    case AccessCheckResult.NotAllowedInternalSystemError:
                        DeliveryItem.Diag.TraceError(0L, "Exception occured when determining permission for sender on public folder");
                        throw new SmtpResponseException(AckReason.PublicFolderSenderValidationFailed, MessageAction.NDR);

                    default:
                        if (folder.IsContentAvailable())
                        {
                            this.messageItem = MessageItem.CreateForDelivery(publicFolderSession, folder.Id, this.context.ReplayItem.InternetMessageId, this.context.ReplayItem.GetValueAsNullable <ExDateTime>(ItemSchema.SentTime));
                            if (this.messageItem != null && this.messageItem.DisposeTracker != null)
                            {
                                this.messageItem.DisposeTracker.AddExtraDataWithStackTrace("DeliveryItem owns messageItem at:{0}{1}");
                            }
                            flag = true;
                        }
                        else
                        {
                            this.ReroutePublicFolderRecipient(publicFolderSession, folder, recipient);
                        }
                        break;
                    }
                }
            }
            finally
            {
                TimeSpan additionalLatency = this.context.EndTrackLatency(LatencyComponent.StoreDriverDeliveryRpc);
                this.context.AddRpcLatency(additionalLatency, "Open message");
            }
            if (flag)
            {
                ItemConversion.ReplayInboundContent(this.context.ReplayItem, this.messageItem);
            }
        }
Пример #12
0
        private void EnsureMailboxExistsOnDatabase(Guid mailboxGuid)
        {
            TenantPublicFolderConfiguration value = TenantPublicFolderConfigurationCache.Instance.GetValue(this.DataObject.OrganizationId);

            if (value.GetLocalMailboxRecipient(mailboxGuid) == null)
            {
                TenantPublicFolderConfigurationCache.Instance.RemoveValue(this.DataObject.OrganizationId);
            }
            using (PublicFolderSession.OpenAsAdmin(this.DataObject.OrganizationId, null, mailboxGuid, null, CultureInfo.CurrentCulture, "Client=Management;Action=UpdatePublicFolderMailbox", null))
            {
            }
        }
Пример #13
0
        public PublicFolderSession GetPublicFolderSession(StoreId folderId)
        {
            PublicFolderSession result;

            using (this.CheckDisposed("GetPublicFolderSession"))
            {
                ExTraceGlobals.SessionTracer.TraceDebug <StoreId>((long)this.GetHashCode(), "PublicFolderSessionCache.GetPublicFolderSession called for folder id: {0}", folderId);
                bool flag = false;
                Guid hierarchyMailboxGuidForUser = this.GetHierarchyMailboxGuidForUser();
                if (this.firstPublicFolderSession != null && this.firstPublicFolderSession.MailboxGuid != hierarchyMailboxGuidForUser)
                {
                    try
                    {
                        using (Folder folder = Folder.Bind(this.firstPublicFolderSession, folderId))
                        {
                            flag = true;
                            if (folder.IsContentAvailable())
                            {
                                return(this.firstPublicFolderSession);
                            }
                            PublicFolderContentMailboxInfo contentMailboxInfo = folder.GetContentMailboxInfo();
                            if (!contentMailboxInfo.IsValid)
                            {
                                throw new InvalidOperationException(string.Format("IsContentAvailable() should have returned true if content mailbox property (value={0}) was not parse-able as a guid", contentMailboxInfo));
                            }
                            return(this.GetPublicFolderSession(contentMailboxInfo.MailboxGuid));
                        }
                    }
                    catch (ObjectNotFoundException)
                    {
                    }
                }
                PublicFolderSession publicFolderSession = null;
                if (!flag)
                {
                    publicFolderSession = this.GetPublicFolderHierarchySession();
                    using (Folder folder2 = Folder.Bind(publicFolderSession, folderId))
                    {
                        if (!folder2.IsContentAvailable())
                        {
                            PublicFolderContentMailboxInfo contentMailboxInfo2 = folder2.GetContentMailboxInfo();
                            if (!contentMailboxInfo2.IsValid)
                            {
                                throw new InvalidOperationException(string.Format("IsContentAvailable() should have returned true if content mailbox property (value={0}) was not parse-able as a guid", contentMailboxInfo2));
                            }
                            return(this.GetPublicFolderSession(contentMailboxInfo2.MailboxGuid));
                        }
                    }
                }
                result = publicFolderSession;
            }
            return(result);
        }
Пример #14
0
 internal static StoreSession OpenSession(ExchangePrincipal principal, GenericIdentity actualExecutingIdentity, bool publicFolderSession = false)
 {
     if (actualExecutingIdentity == null)
     {
         throw new ArgumentNullException("actualExecutingIdentity");
     }
     if (!publicFolderSession)
     {
         return(MailboxSession.OpenAsAdmin(principal, CultureInfo.InvariantCulture, "Client=EDiscoverySearch;Action=Search;Interactive=False", actualExecutingIdentity, true));
     }
     return(PublicFolderSession.OpenAsAdmin(principal.MailboxInfo.OrganizationId, null, principal.MailboxInfo.MailboxGuid, null, CultureInfo.InvariantCulture, "Client=EDiscoverySearch;Action=Search;Interactive=False", null));
 }
Пример #15
0
 public PublicFolderSynchronizerLogger(PublicFolderSession publicFolderSession, FolderOperationCounter folderOperationCount, Guid correlationId) : base(publicFolderSession, "PublicFolderSyncInfo", "PublicFolderLastSyncCylceLog", new Guid?(correlationId))
 {
     ArgumentValidator.ThrowIfNull("folderOperationCount", folderOperationCount);
     this.logComponent         = "PublicFolderSyncLog";
     this.logSuffixName        = "PublicFolderSyncLog";
     this.folderOperationCount = folderOperationCount;
     using (DisposeGuard disposeGuard = this.Guard())
     {
         base.LogEvent(LogEventType.Entry, "Sync started");
         disposeGuard.Success();
     }
 }
        public override void SetMailboxOwnerAsSender(MessageItem message)
        {
            PublicFolderSession publicFolderSession = base.StoreSession as PublicFolderSession;

            if (base.CurrentFolder.PropertyBag.GetValueOrDefault <bool>(FolderSchema.MailEnabled))
            {
                Exception ex = null;
                try
                {
                    byte[] valueOrDefault = base.CurrentFolder.PropertyBag.GetValueOrDefault <byte[]>(FolderSchema.ProxyGuid);
                    if (valueOrDefault != null && valueOrDefault.Length == 16)
                    {
                        IRecipientSession adrecipientSession = publicFolderSession.GetADRecipientSession(true, ConsistencyMode.PartiallyConsistent);
                        ADRawEntry        adrawEntry         = adrecipientSession.Read(new ADObjectId(valueOrDefault)) as ADPublicFolder;
                        if (adrawEntry != null)
                        {
                            message.From = new Participant(adrawEntry);
                            return;
                        }
                    }
                    ex = new ObjectNotFoundException(ServerStrings.ExItemNotFound);
                }
                catch (ADTransientException ex2)
                {
                    ex = ex2;
                }
                catch (ADExternalException ex3)
                {
                    ex = ex3;
                }
                catch (ADOperationException ex4)
                {
                    ex = ex4;
                }
                catch (DataValidationException ex5)
                {
                    ex = ex5;
                }
                catch (ObjectNotFoundException ex6)
                {
                    ex = ex6;
                }
                if (ex != null)
                {
                    StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_PFRuleSettingFromAddressFailure, base.CurrentFolder.StoreObjectId.ToHexEntryId(), new object[]
                    {
                        ex
                    });
                }
            }
            message.From = (publicFolderSession.ConnectAsParticipant ?? new Participant(publicFolderSession.MailboxPrincipal));
        }
 protected override void InternalDispose(bool disposing)
 {
     if (disposing)
     {
         if (this.publicFolderSessionCache != null)
         {
             this.publicFolderSessionCache.Dispose();
             this.publicFolderSessionCache = null;
         }
         this.PublicFolderSession = null;
     }
     base.InternalDispose(disposing);
 }
        // Token: 0x0600191D RID: 6429 RVA: 0x000922A4 File Offset: 0x000904A4
        private Folder GetFolderFromPath(string path, bool isPublicFolder)
        {
            string[] array = path.Split(new char[]
            {
                '/',
                '\\'
            }, StringSplitOptions.RemoveEmptyEntries);
            CultureInfo          userCulture   = Culture.GetUserCulture();
            StoreObjectId        storeObjectId = null;
            StoreSession         storeSession  = null;
            OwaStoreObjectIdType objectIdType  = OwaStoreObjectIdType.MailBoxObject;

            try
            {
                if (isPublicFolder)
                {
                    storeSession  = PublicFolderSession.OpenAsAdmin(this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.userContext.ExchangePrincipal, Guid.Empty, null, userCulture, "Client=OWA;Action=WebPart + Admin + GetFolderFromPath", null);
                    storeObjectId = this.userContext.PublicFolderRootId;
                    objectIdType  = OwaStoreObjectIdType.PublicStoreFolder;
                }
                else
                {
                    storeSession = MailboxSession.OpenAsAdmin(this.owaContext.ExchangePrincipal, userCulture, "Client=OWA;Action=WebPart + Admin + GetFolderFromPath");
                    GccUtils.SetStoreSessionClientIPEndpointsFromHttpRequest(storeSession, this.owaContext.HttpContext.Request);
                    storeObjectId = this.userContext.GetRootFolderId(this.userContext.MailboxSession);
                }
                for (int i = 0; i < array.Length; i++)
                {
                    object[][] folderIdByDisplayName = this.GetFolderIdByDisplayName(array[i], storeObjectId, storeSession);
                    if (folderIdByDisplayName == null || folderIdByDisplayName.Length == 0)
                    {
                        return(null);
                    }
                    storeObjectId = ((VersionedId)folderIdByDisplayName[0][0]).ObjectId;
                }
            }
            finally
            {
                if (storeSession != null)
                {
                    storeSession.Dispose();
                    storeSession = null;
                }
            }
            if (storeObjectId == null)
            {
                return(null);
            }
            return(this.GetFolderFromId(OwaStoreObjectId.CreateFromFolderId(storeObjectId, objectIdType)));
        }
Пример #19
0
        public PublicFolderSession GetPublicFolderSession(Guid publicFolderMailboxGuid)
        {
            PublicFolderSession result;

            using (this.CheckDisposed("GetPublicFolderSession"))
            {
                ExTraceGlobals.SessionTracer.TraceDebug((long)this.GetHashCode(), "PublicFolderSessionCache.GetPublicFolderContentSession called");
                if (publicFolderMailboxGuid == PublicFolderSession.HierarchyMailboxGuidAlias)
                {
                    publicFolderMailboxGuid = this.GetHierarchyMailboxGuidForUser();
                }
                PublicFolderSession publicFolderSession;
                if (this.openedSessions.TryGetValue(publicFolderMailboxGuid, out publicFolderSession))
                {
                    result = publicFolderSession;
                }
                else
                {
                    lock (this.lockObject)
                    {
                        if (this.openedSessions.TryGetValue(publicFolderMailboxGuid, out publicFolderSession))
                        {
                            return(publicFolderSession);
                        }
                        if (this.openSessionAsAdmin)
                        {
                            publicFolderSession = PublicFolderSession.OpenAsAdmin(this.organizationId, this.connectAsPrincipal, publicFolderMailboxGuid, (this.clientSecurityContext == null) ? null : new WindowsPrincipal(this.clientSecurityContext.Identity), this.cultureInfo, this.clientInfoString, this.budget);
                        }
                        else
                        {
                            publicFolderSession = PublicFolderSession.Open(this.connectAsPrincipal, publicFolderMailboxGuid, this.clientSecurityContext, this.cultureInfo, this.clientInfoString);
                            publicFolderSession.AccountingObject = this.budget;
                        }
                        if (this.timeZone != null)
                        {
                            publicFolderSession.ExTimeZone = this.timeZone;
                        }
                        if (this.firstPublicFolderSession == null)
                        {
                            this.firstPublicFolderSession = publicFolderSession;
                        }
                        this.openedSessions.Add(publicFolderSession.MailboxGuid, publicFolderSession);
                    }
                    result = publicFolderSession;
                }
            }
            return(result);
        }
        public override MessageItem CreateMessageItem(PropertyDefinition[] prefetchProperties)
        {
            PublicFolderSession publicFolderSession = base.StoreSession as PublicFolderSession;
            MessageItem         result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                MessageItem messageItem = MessageItem.Create(publicFolderSession, publicFolderSession.GetInternalSubmissionFolderId());
                disposeGuard.Add <MessageItem>(messageItem);
                messageItem.Load(prefetchProperties);
                messageItem.SaveFlags |= PropertyBagSaveFlags.IgnoreAccessDeniedErrors;
                disposeGuard.Success();
                result = messageItem;
            }
            return(result);
        }
Пример #21
0
 private StoreSession OpenPublicFolderMailboxSession(Guid mdbGuid, ADUser adUser)
 {
     try
     {
         return(PublicFolderSession.OpenAsAdmin(adUser.OrganizationId, null, adUser.ExchangeGuid, null, CultureInfo.InvariantCulture, "Client=Management;Action=GetFailedDocuments", null));
     }
     catch (StoragePermanentException exception)
     {
         base.WriteError(exception, ErrorCategory.ReadError, null);
     }
     catch (StorageTransientException exception2)
     {
         base.WriteError(exception2, ErrorCategory.ReadError, null);
     }
     return(null);
 }
        internal static PublicFolderMailboxDiagnosticsInfo Load(PublicFolderSession session, DiagnosticsLoadFlags loadFlags, Action <LocalizedString, LocalizedString, int> writeProgress)
        {
            PublicFolderMailboxDiagnosticsInfo publicFolderMailboxDiagnosticsInfo = new PublicFolderMailboxDiagnosticsInfo("Public Folder Diagnostics Information");

            publicFolderMailboxDiagnosticsInfo.SyncInfo      = (PublicFolderMailboxDiagnosticsInfo.LoadMailboxInfo <PublicFolderMailboxSynchronizerInfo>(session, "PublicFolderSyncInfo", "PublicFolderLastSyncCylceLog") as PublicFolderMailboxSynchronizerInfo);
            publicFolderMailboxDiagnosticsInfo.AssistantInfo = (PublicFolderMailboxDiagnosticsInfo.LoadMailboxInfo <PublicFolderMailboxAssistantInfo>(session, "PublicFolderAssistantInfo", "PublicFolderLastAssistantCycleLog") as PublicFolderMailboxAssistantInfo);
            if ((loadFlags & DiagnosticsLoadFlags.DumpsterInfo) != DiagnosticsLoadFlags.Default)
            {
                publicFolderMailboxDiagnosticsInfo.DumpsterInfo = PublicFolderMailboxDumpsterInfo.LoadInfo(session, writeProgress);
            }
            if ((loadFlags & DiagnosticsLoadFlags.HierarchyInfo) != DiagnosticsLoadFlags.Default)
            {
                publicFolderMailboxDiagnosticsInfo.HierarchyInfo = PublicFolderMailboxHierarchyInfo.LoadInfo(session, writeProgress);
            }
            return(publicFolderMailboxDiagnosticsInfo);
        }
Пример #23
0
        List <FolderRec> IMailbox.EnumerateFolderHierarchy(EnumerateFolderHierarchyFlags flags, PropTag[] additionalPtagsToLoad)
        {
            MrsTracer.Provider.Function("StorageMailbox.EnumerateFolderHierarchy({0})", new object[]
            {
                flags
            });
            base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None);
            List <FolderRec> list = new List <FolderRec>(50);

            using (base.RHTracker.Start())
            {
                bool flag = flags.HasFlag(EnumerateFolderHierarchyFlags.WellKnownPublicFoldersOnly);
                NativeStorePropertyDefinition[] propertiesToLoad;
                if (additionalPtagsToLoad == null || additionalPtagsToLoad.Length == 0)
                {
                    propertiesToLoad = this.FolderPropertyDefinitionsToLoad;
                }
                else
                {
                    List <NativeStorePropertyDefinition> list2 = new List <NativeStorePropertyDefinition>();
                    list2.AddRange(this.ConvertPropTagsToDefinitions(additionalPtagsToLoad));
                    list2.AddRange(this.FolderPropertyDefinitionsToLoad);
                    propertiesToLoad = list2.ToArray();
                }
                if (!flag)
                {
                    this.LoadFolderHierarchy(this.GetFolderId(null), propertiesToLoad, list);
                }
                else
                {
                    PublicFolderSession publicFolderSession = this.GetPublicFolderSession();
                    list.Add(this.GetFolderRec(this.GetFolderId(null), propertiesToLoad));
                    list.Add(this.GetFolderRec(publicFolderSession.GetIpmSubtreeFolderId(), propertiesToLoad));
                    list.Add(this.GetFolderRec(publicFolderSession.GetNonIpmSubtreeFolderId(), propertiesToLoad));
                    list.Add(this.GetFolderRec(publicFolderSession.GetEFormsRegistryFolderId(), propertiesToLoad));
                    list.Add(this.GetFolderRec(publicFolderSession.GetAsyncDeleteStateFolderId(), propertiesToLoad));
                    list.Add(this.GetFolderRec(publicFolderSession.GetDumpsterRootFolderId(), propertiesToLoad));
                    list.Add(this.GetFolderRec(publicFolderSession.GetInternalSubmissionFolderId(), propertiesToLoad));
                    list.Add(this.GetFolderRec(publicFolderSession.GetTombstonesRootFolderId(), propertiesToLoad));
                }
            }
            MrsTracer.Provider.Debug("Loaded {0} folders", new object[]
            {
                list.Count
            });
            return(list);
        }
        // Token: 0x06000ED5 RID: 3797 RVA: 0x00058618 File Offset: 0x00056818
        protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            PublicFolderSession publicFolderSession = invokeArgs.StoreSession as PublicFolderSession;

            if (publicFolderSession == null)
            {
                return;
            }
            PublicFolderAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "PublicFolderAssistant::InvokeInternal::{0} - Begin processing of public folder mailbox", publicFolderSession.DisplayAddress);
            new PublicFolderHierarchySyncProcessor(publicFolderSession, PublicFolderAssistant.Tracer).Invoke();
            new PublicFolderItemProcessor(publicFolderSession, PublicFolderAssistant.Tracer).Invoke();
            using (PublicFolderSplitProcessor publicFolderSplitProcessor = new PublicFolderSplitProcessor(publicFolderSession, PublicFolderAssistant.Tracer))
            {
                publicFolderSplitProcessor.Invoke();
            }
            PublicFolderAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "PublicFolderAssistant::InvokeInternal::{0} - End processing of public folder mailbox", publicFolderSession.DisplayAddress);
        }
Пример #25
0
        private IEnumerable <PublicFolderItemStatistics> FindItems(PublicFolder publicFolder)
        {
            PropertyDefinition[] xsoProperties = PublicFolderItemStatistics.StaticSchema.AllDependentXsoProperties;
            PublicFolderSession  publicFolderContentSession = null;

            if (this.mailboxGuid == Guid.Empty)
            {
                publicFolderContentSession = this.publicFolderDataProvider.PublicFolderSessionCache.GetPublicFolderSession(publicFolder.InternalFolderIdentity.ObjectId);
            }
            else
            {
                publicFolderContentSession = this.publicFolderDataProvider.PublicFolderSessionCache.GetPublicFolderSession(this.mailboxGuid);
            }
            using (Folder xsoFolder = Folder.Bind(publicFolderContentSession, publicFolder.InternalFolderIdentity))
            {
                using (QueryResult itemQueryResult = xsoFolder.ItemQuery(ItemQueryType.None, null, GetPublicFolderItemStatistics.sortByProperties, xsoProperties))
                {
                    for (;;)
                    {
                        object[][] rowResults = itemQueryResult.GetRows(100);
                        if (rowResults == null || rowResults.Length <= 0)
                        {
                            break;
                        }
                        foreach (object[] row in rowResults)
                        {
                            PublicFolderItemStatistics itemStatistics = new PublicFolderItemStatistics();
                            itemStatistics.LoadDataFromXsoRows(publicFolderContentSession.MailboxPrincipal.ObjectId, row, xsoProperties);
                            if (base.NeedSuppressingPiiData)
                            {
                                itemStatistics.PublicFolderName = SuppressingPiiData.Redact(this.Identity.ToString());
                            }
                            else
                            {
                                itemStatistics.PublicFolderName = this.Identity.ToString();
                            }
                            yield return(itemStatistics);
                        }
                    }
                }
            }
            yield break;
        }
        private void EnsureExternalFreeBusyFolder(Server localServer, PublicFolderDatabase[] publicFolderDatabases)
        {
            Organization orgContainer = this.configurationSession.GetOrgContainer();

            if (orgContainer == null)
            {
                base.WriteVerbose(Strings.InstallFreeBusyFolderCannotGetOrganizationContainer);
                return;
            }
            string legacyDN = orgContainer.LegacyExchangeDN + "/ou=External (FYDIBOHF25SPDLT)";

            if (this.IsExternalFreeBusyFolderCreated(legacyDN, publicFolderDatabases))
            {
                base.WriteVerbose(Strings.InstallFreeBusyFolderAlreadyExists);
                return;
            }
            using (PublicFolderSession publicFolderSession = this.GetPublicFolderSession(localServer))
            {
                StoreObjectId freeBusyFolderId = FreeBusyFolder.GetFreeBusyFolderId(publicFolderSession, legacyDN, FreeBusyFolderDisposition.CreateIfNeeded);
                if (freeBusyFolderId == null)
                {
                    base.WriteVerbose(Strings.InstallFreeBusyFolderUnableToCreateFolder);
                }
                else
                {
                    base.WriteVerbose(Strings.InstallFreeBusyFolderCreatedFolder(freeBusyFolderId.ToString()));
                    using (Folder folder = Folder.Bind(publicFolderSession, freeBusyFolderId, new PropertyDefinition[]
                    {
                        FolderSchema.ReplicaList
                    }))
                    {
                        string[] array       = Array.ConvertAll <PublicFolderDatabase, string>(publicFolderDatabases, (PublicFolderDatabase database) => database.ExchangeLegacyDN);
                        string[] secondArray = (string[])folder[FolderSchema.ReplicaList];
                        if (!this.IsEqualsArrayOfLegacyDN(array, secondArray))
                        {
                            folder[FolderSchema.ReplicaList] = array;
                            folder.Save();
                            folder.Load();
                        }
                    }
                }
            }
        }
Пример #27
0
 private void ExecuteSyncStateOperation(Action <StoreSession, CoreFolder> operation)
 {
     using (base.RHTracker.Start())
     {
         if (base.IsPublicFolderMove || base.IsPublicFolderMailboxRestore)
         {
             PublicFolderSession publicFolderSession = this.GetPublicFolderSession();
             using (CoreFolder coreFolder = CoreFolder.Bind(publicFolderSession, publicFolderSession.GetTombstonesRootFolderId()))
             {
                 operation(publicFolderSession, coreFolder);
                 goto IL_A9;
             }
         }
         MailboxSession mailboxSession = null;
         bool           flag           = false;
         try
         {
             if (base.UseHomeMDB)
             {
                 mailboxSession = this.GetMailboxSession();
             }
             else
             {
                 mailboxSession = this.OpenSystemMailbox();
                 flag           = true;
             }
             using (CoreFolder coreFolder2 = CoreFolder.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration), false, "MailboxReplicationService SyncStates", CreateMode.OpenIfExists))
             {
                 coreFolder2.Save(SaveMode.FailOnAnyConflict);
                 operation(mailboxSession, coreFolder2);
             }
         }
         finally
         {
             if (flag && mailboxSession != null)
             {
                 mailboxSession.Dispose();
             }
         }
         IL_A9 :;
     }
 }
Пример #28
0
 internal static void SyncPublicFolder(IConfigurationSession configurationSession, StoreObjectId folderId)
 {
     using (PublicFolderDataProvider publicFolderDataProvider = new PublicFolderDataProvider(configurationSession, "*-PublicFolderClientPermission", Guid.Empty))
     {
         PublicFolderSession publicFolderSession = publicFolderDataProvider.PublicFolderSession;
         using (CoreFolder coreFolder = CoreFolder.Bind(publicFolderSession, folderId, new PropertyDefinition[]
         {
             CoreFolderSchema.AclTableAndSecurityDescriptor
         }))
         {
             PublicFolderContentMailboxInfo contentMailboxInfo = coreFolder.GetContentMailboxInfo();
             Guid guid = contentMailboxInfo.IsValid ? contentMailboxInfo.MailboxGuid : Guid.Empty;
             ExchangePrincipal contentMailboxPrincipal;
             if (guid != Guid.Empty && guid != publicFolderSession.MailboxGuid && PublicFolderSession.TryGetPublicFolderMailboxPrincipal(publicFolderSession.OrganizationId, guid, true, out contentMailboxPrincipal))
             {
                 PublicFolderSyncJobRpc.SyncFolder(contentMailboxPrincipal, folderId.ProviderLevelItemId);
             }
         }
     }
 }
Пример #29
0
        private static Item CreateFreeBusyItemInternal(PublicFolderSession session, StoreObjectId freeBusyFolderId, string legacyDN)
        {
            string freeBusyItemSubject = FreeBusyFolder.GetFreeBusyItemSubject(legacyDN);
            Item   item = Item.Create(session, "IPM.Post", freeBusyFolderId);
            bool   flag = false;

            try
            {
                item[ItemSchema.Subject] = freeBusyItemSubject;
                item[FreeBusyItemSchema.ScheduleInfoRecipientLegacyDn] = legacyDN;
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    item.Dispose();
                }
            }
            return(item);
        }
        // Token: 0x06000F5F RID: 3935 RVA: 0x0005B8C8 File Offset: 0x00059AC8
        private void SyncAndReturn(Guid mailboxGuid)
        {
            this.splitOperationState.PartialStep = true;
            ExchangePrincipal contentMailboxPrincipal;

            if (!PublicFolderSession.TryGetPublicFolderMailboxPrincipal(base.CurrentPublicFolderSession.OrganizationId, mailboxGuid, false, out contentMailboxPrincipal))
            {
                throw new ObjectNotFoundException(ServerStrings.PublicFolderMailboxNotFound);
            }
            PublicFolderSyncJobState publicFolderSyncJobState = PublicFolderSyncJobRpc.StartSyncHierarchy(contentMailboxPrincipal, false);

            if (PublicFolderSplitHelper.HasSyncFailure(publicFolderSyncJobState))
            {
                this.splitOperationState.Error = publicFolderSyncJobState.LastError;
                return;
            }
            if ((int)this.splitOperationState.PartialStepCount > PrepareTargetMailboxOperation.PartialStepIterationLimit)
            {
                this.splitOperationState.Error = new PartialStepsOverLimitException("Long running sync operation", PrepareTargetMailboxOperation.PartialStepIterationLimit);
            }
        }