コード例 #1
0
 public static IStorePropertyBag[] FindItemsFromInternetId(MailboxSession session, string internetMessageId, params PropertyDefinition[] propertyDefinitions)
 {
     return(AllItemsFolderHelper.FindItemsFromInternetId(session, internetMessageId, ItemQueryType.None, propertyDefinitions));
 }
コード例 #2
0
        internal CultureInfo GetBestCulture(CultureInfo stampedCulture, string inboxDisplayName, MailboxSession session)
        {
            List <CultureInfo> list = new List <CultureInfo>();

            if (stampedCulture != null)
            {
                list.Add(stampedCulture);
            }
            if (inboxDisplayName != null)
            {
                CultureInfo cultureInfo = session.MailboxOwner.PreferredCultures.FirstOrDefault <CultureInfo>();
                if (cultureInfo != null)
                {
                    string localizableDisplayName = DefaultFolderManager.GetLocalizableDisplayName(DefaultFolderType.Inbox, cultureInfo);
                    if (string.Equals(localizableDisplayName, inboxDisplayName, StringComparison.OrdinalIgnoreCase))
                    {
                        list.Add(cultureInfo);
                    }
                }
            }
            list.Add(session.InternalPreferedCulture);
            return(Util.CultureSelector.GetPreferedCulture(list.ToArray()));
        }
コード例 #3
0
 // Token: 0x060002C5 RID: 709 RVA: 0x00010ADC File Offset: 0x0000ECDC
 internal void InvokeInternal(MailboxSession mailboxSession)
 {
     try
     {
         if (mailboxSession.MailboxOwner.MailboxInfo.IsArchive)
         {
             ElcSubAssistant.Tracer.TraceError <ElcFolderSubAssistant, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Mailbox owner {1} is archive mailbox. Skipping MRM version 1.", this, mailboxSession.MailboxOwner);
         }
         else
         {
             ElcSubAssistant.Tracer.TraceDebug <ElcFolderSubAssistant, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Collecting ELC information for mailbox '{1}'.", this, mailboxSession.MailboxOwner);
             ElcUserFolderInformation elcUserFolderInformation = new ElcUserFolderInformation(mailboxSession, base.ElcAssistantType.AdCache.GetAllFolders(mailboxSession.MailboxOwner));
             try
             {
                 elcUserFolderInformation.Build();
             }
             catch (ELCNoMatchingOrgFoldersException ex)
             {
                 ElcSubAssistant.Tracer.TraceDebug <ElcFolderSubAssistant, ELCNoMatchingOrgFoldersException>((long)this.GetHashCode(), "{0}: An org folder attached to this user could not be found in the list of all folders. Exception: {1}. ", this, ex);
                 Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_InvalidElcDataInAD, null, new object[]
                 {
                     mailboxSession.MailboxOwner,
                     ex.ToString()
                 });
                 throw;
             }
             if (!elcUserFolderInformation.NeedsElcEnforcement())
             {
                 ElcSubAssistant.Tracer.TraceDebug <ElcFolderSubAssistant, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Mailbox '{1}' does not require ELC processing.", this, mailboxSession.MailboxOwner);
             }
             else
             {
                 base.ThrowIfShuttingDown(mailboxSession.MailboxOwner);
                 if (this.elcAuditLog.LoggingEnabled)
                 {
                     this.elcAuditLog.Append("Starting to process mailbox: " + mailboxSession.MailboxOwner, base.ElcAssistantType.ToString());
                 }
                 this.folderProvisioner.Invoke(elcUserFolderInformation);
                 ElcSubAssistant.Tracer.TraceDebug <ElcFolderSubAssistant, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Invoke of FolderProvisioner has been called for mailbox '{1}'.", this, mailboxSession.MailboxOwner);
                 List <AdFolderData> userAdFolders = elcUserFolderInformation.UserAdFolders;
                 if (userAdFolders == null || userAdFolders.Count == 0)
                 {
                     ElcSubAssistant.Tracer.TraceDebug <ElcFolderSubAssistant, IExchangePrincipal>((long)this.GetHashCode(), "{0}: No policies exist in AD for mailbox '{1}'. Skipping this mailbox.", this, mailboxSession.MailboxOwner);
                 }
                 else
                 {
                     ElcSubAssistant.Tracer.TraceDebug <ElcFolderSubAssistant, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Policies exist in AD for mailbox '{1}'. Processing this mailbox.", this, mailboxSession.MailboxOwner);
                     this.enforcerManager.Invoke(mailboxSession, elcUserFolderInformation);
                 }
             }
         }
     }
     catch (DataValidationException ex2)
     {
         ElcSubAssistant.Tracer.TraceError <ElcFolderSubAssistant, DataValidationException, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Invalid data in the AD '{1}' found while processing mailbox '{2}'. Skipping the mailbox.", this, ex2, mailboxSession.MailboxOwner);
         Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_InvalidElcDataInAD, null, new object[]
         {
             mailboxSession.MailboxOwner,
             ex2.ToString()
         });
         throw new SkipException(ex2);
     }
 }
コード例 #4
0
        // Token: 0x06002446 RID: 9286 RVA: 0x000D1C1C File Offset: 0x000CFE1C
        private static NavigationTree CreateFavoriteTreeByFolderLists(UserContext userContext, NavigationNodeCollection navigationCollection, NavigationTree.NormalAndSearchFolderList[] normalAndSearchFolderLists)
        {
            if (navigationCollection.GroupSection != NavigationNodeGroupSection.First)
            {
                throw new ArgumentException("Should pass a collection represents favorites.");
            }
            NavigationTree navigationTree    = new NavigationTree(userContext, new InvisibleRootTreeNode(userContext), NavigationNodeGroupSection.First);
            List <NavigationNodeFolder> list = new List <NavigationNodeFolder>();

            List <StoreObjectId>[] array = new List <StoreObjectId> [normalAndSearchFolderLists.Length];
            for (int i = 0; i < normalAndSearchFolderLists.Length; i++)
            {
                array[i] = new List <StoreObjectId>();
            }
            NavigationNodeGroup           navigationNodeGroup           = navigationCollection[0];
            NavigationGroupHeaderTreeNode navigationGroupHeaderTreeNode = new NavigationGroupHeaderTreeNode(userContext, navigationNodeGroup);

            foreach (NavigationNodeFolder navigationNodeFolder in navigationNodeGroup.Children)
            {
                for (int j = 0; j < normalAndSearchFolderLists.Length; j++)
                {
                    MailboxSession mailboxSession          = normalAndSearchFolderLists[j].MailboxSession;
                    FolderList     deepHierarchyFolderList = normalAndSearchFolderLists[j].DeepHierarchyFolderList;
                    FolderList     searchFolderList        = normalAndSearchFolderLists[j].SearchFolderList;
                    Dictionary <Guid, StoreObjectId> searchFolderGuidToIdMapping = normalAndSearchFolderLists[j].SearchFolderGuidToIdMapping;
                    if (navigationNodeFolder.IsValid && navigationNodeFolder.IsFolderInSpecificMailboxSession(mailboxSession) && navigationNodeFolder.FolderId != null && !navigationNodeFolder.IsFlagSet(NavigationNodeFlags.PublicFolderFavorite))
                    {
                        bool flag = navigationNodeFolder.NavigationNodeType == NavigationNodeType.SmartFolder;
                        if (!flag || (searchFolderList != null && userContext.IsFeatureEnabled(Feature.SearchFolders)))
                        {
                            StoreObjectId folderId;
                            if (flag && !navigationNodeFolder.AssociatedSearchFolderId.Equals(Guid.Empty))
                            {
                                searchFolderGuidToIdMapping.TryGetValue(navigationNodeFolder.AssociatedSearchFolderId, out folderId);
                            }
                            else
                            {
                                folderId = navigationNodeFolder.FolderId;
                            }
                            if (folderId != null)
                            {
                                object[] array2 = flag ? searchFolderList.GetFolderProperties(folderId) : deepHierarchyFolderList.GetFolderProperties(folderId);
                                if (array2 != null)
                                {
                                    string text = (flag ? searchFolderList.GetFolderProperty(folderId, StoreObjectSchema.ContainerClass) : deepHierarchyFolderList.GetFolderProperty(folderId, StoreObjectSchema.ContainerClass)) as string;
                                    if (string.IsNullOrEmpty(text) || ObjectClass.IsOfClass(text, "IPF.Note"))
                                    {
                                        if (navigationNodeFolder.IsFilteredView && !deepHierarchyFolderList.ContainsFolder(navigationNodeFolder.FilterSourceFolder) && !searchFolderList.ContainsFolder(navigationNodeFolder.FilterSourceFolder))
                                        {
                                            list.Add(navigationNodeFolder);
                                            array[j].Add(folderId);
                                        }
                                        else
                                        {
                                            StoreObjectId storeObjectId = null;
                                            if (!flag)
                                            {
                                                StoreObjectId storeObjectId2 = folderId;
                                                while (storeObjectId == null && storeObjectId2 != null)
                                                {
                                                    object folderProperty = deepHierarchyFolderList.GetFolderProperty(storeObjectId2, FolderSchema.Id);
                                                    if (folderProperty == null)
                                                    {
                                                        break;
                                                    }
                                                    storeObjectId2 = ((VersionedId)folderProperty).ObjectId;
                                                    DefaultFolderType defaultFolderType = Utilities.GetDefaultFolderType(mailboxSession, storeObjectId2);
                                                    if (defaultFolderType == DefaultFolderType.Root)
                                                    {
                                                        break;
                                                    }
                                                    object folderProperty2 = deepHierarchyFolderList.GetFolderProperty(storeObjectId2, FolderSchema.AdminFolderFlags);
                                                    if (folderProperty2 is int && (int)folderProperty2 != 0)
                                                    {
                                                        storeObjectId = storeObjectId2;
                                                    }
                                                    else if (Utilities.IsSpecialFolderType(defaultFolderType) && !string.IsNullOrEmpty(deepHierarchyFolderList.GetFolderProperty(storeObjectId2, FolderSchema.ELCPolicyIds) as string))
                                                    {
                                                        storeObjectId = storeObjectId2;
                                                    }
                                                    else
                                                    {
                                                        object folderProperty3 = deepHierarchyFolderList.GetFolderProperty(storeObjectId2, StoreObjectSchema.ParentEntryId);
                                                        if (folderProperty3 is byte[])
                                                        {
                                                            storeObjectId2 = StoreObjectId.FromProviderSpecificId(folderProperty3 as byte[], StoreObjectType.Folder);
                                                        }
                                                        else
                                                        {
                                                            storeObjectId2 = null;
                                                        }
                                                    }
                                                }
                                            }
                                            Dictionary <PropertyDefinition, int> propertyMap = flag ? searchFolderList.QueryPropertyMap : deepHierarchyFolderList.QueryPropertyMap;
                                            navigationGroupHeaderTreeNode.AddChild(new NavigationFolderTreeNode(userContext, navigationNodeFolder, storeObjectId, array2, propertyMap));
                                        }
                                    }
                                    else if (!flag)
                                    {
                                        list.Add(navigationNodeFolder);
                                    }
                                }
                                else if (navigationNodeFolder.IsFilteredView || !flag)
                                {
                                    list.Add(navigationNodeFolder);
                                }
                            }
                        }
                    }
                }
            }
            object folderProperty4 = normalAndSearchFolderLists[0].DeepHierarchyFolderList.GetFolderProperty(userContext.GetRootFolderId(userContext.MailboxSession), ViewStateProperties.TreeNodeCollapseStatus);

            if (folderProperty4 is int)
            {
                navigationGroupHeaderTreeNode.IsExpanded = !Utilities.IsFlagSet((int)folderProperty4, 2);
            }
            else
            {
                navigationGroupHeaderTreeNode.IsExpanded = true;
            }
            navigationTree.RootNode.AddChild(navigationGroupHeaderTreeNode);
            if (list.Count > 0)
            {
                foreach (NavigationNodeFolder navigationNodeFolder2 in list)
                {
                    if (navigationNodeFolder2.NavigationNodeId != null)
                    {
                        navigationCollection.RemoveFolderOrGroupByNodeId(navigationNodeFolder2.NavigationNodeId.ObjectId);
                    }
                }
                navigationCollection.Save(userContext.MailboxSession);
            }
            for (int k = 0; k < array.Length; k++)
            {
                List <StoreObjectId> list2 = array[k];
                if (list2.Count > 0)
                {
                    Utilities.DeleteFolders(normalAndSearchFolderLists[k].MailboxSession, DeleteItemFlags.SoftDelete, list2.ToArray());
                }
            }
            return(navigationTree);
        }
コード例 #5
0
 internal static DefaultFolderManager Create(MailboxSession session)
 {
     return(DefaultFolderManager.Create(session, OpenMailboxSessionFlags.None, MailboxSession.AllDefaultFolders));
 }
コード例 #6
0
        // Token: 0x06000133 RID: 307 RVA: 0x000079F8 File Offset: 0x00005BF8
        internal static void HandleEventInternal(MapiEvent mapiEvent, MailboxSession session, StoreObject storeItem, MailboxData mailboxData, List <KeyValuePair <string, object> > customDataToLog)
        {
            InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", mapiEvent.ToString());
            Exception ex = null;

            try
            {
                ArgumentValidator.ThrowIfNull("session", session);
                if (storeItem == null)
                {
                    InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "NullStoreItem");
                }
                else
                {
                    MessageItem messageItem = storeItem as MessageItem;
                    if (messageItem == null)
                    {
                        InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "StoreItemIsNotMessageItem");
                    }
                    else
                    {
                        if (InferenceProcessor.IsInferenceProcessingNeeded(mapiEvent))
                        {
                            InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "InferenceProcessingNeeded");
                            if (!messageItem.GetValueOrDefault <bool>(ItemSchema.InferenceProcessingNeeded, false))
                            {
                                return;
                            }
                            try
                            {
                                messageItem.DeleteProperties(new PropertyDefinition[]
                                {
                                    ItemSchema.InferenceProcessingNeeded
                                });
                                InferenceProcessingActions valueOrDefault = (InferenceProcessingActions)messageItem.GetValueOrDefault <long>(ItemSchema.InferenceProcessingActions, 0L);
                                messageItem.DeleteProperties(new PropertyDefinition[]
                                {
                                    ItemSchema.InferenceProcessingActions
                                });
                                if (valueOrDefault.HasFlag(InferenceProcessingActions.ProcessImplicitMarkAsNotClutter))
                                {
                                    InferenceProcessor.HandleImplicitMarkAsNotClutter(mapiEvent, session, messageItem, customDataToLog);
                                    goto IL_1C6;
                                }
                                throw new ArgumentException("No actionable flag is set on InferenceProcessingActions, but InferenceProcessingNeeded is true");
                            }
                            finally
                            {
                                if (messageItem.IsDirty)
                                {
                                    messageItem.Save(SaveMode.ResolveConflicts);
                                }
                            }
                        }
                        if (InferenceProcessor.IsOutlookActivityProcessingNeeded(mapiEvent, mailboxData))
                        {
                            InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "ProcessOutlookActivity");
                            if (session.IsDefaultFolderType(messageItem.ParentId) != DefaultFolderType.Inbox)
                            {
                                InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "ActivityItemNotInExpectedFolder");
                                return;
                            }
                            try
                            {
                                int num = OutlookActivityProcessor.Process(session, messageItem);
                                InferenceProcessor.Log(customDataToLog, "NumOfOutlookActivityItemsProcessed", num);
                            }
                            catch (OutlookActivityParsingException value)
                            {
                                InferenceProcessor.Log(customDataToLog, "OutlookActivityParsingException", value);
                            }
                            using (Folder folder = Folder.Bind(session, DefaultFolderType.Inbox))
                            {
                                folder.DeleteObjects(DeleteItemFlags.HardDelete, new StoreId[]
                                {
                                    messageItem.Id
                                });
                                goto IL_1C6;
                            }
                        }
                        throw new ArgumentException("We should not get an event that's not interested by InferenceProcessor" + mapiEvent.ToString());
                        IL_1C6 :;
                    }
                }
            }
            catch (Exception ex2)
            {
                ex = ex2;
            }
            finally
            {
                if (ex != null)
                {
                    InferenceProcessor.Log(customDataToLog, "Exception", ex.ToString());
                }
                InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", (ex == null) ? "InvokeSucceeded" : "InvokeFailed");
            }
        }
コード例 #7
0
ファイル: GlobalInfo.cs プロジェクト: YHZX2013/exchange_diff
        public static GlobalInfo LoadFromMailbox(MailboxSession mailboxSession, SyncStateStorage syncStateStorage, ProtocolLogger protocolLogger)
        {
            bool flag;

            return(GlobalInfo.LoadFromMailbox(mailboxSession, syncStateStorage, protocolLogger, out flag));
        }
コード例 #8
0
 public NotificationManager(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator) : this(session, snapshot, frontEndLocator, null)
 {
 }
コード例 #9
0
 public static void SendNotification(ClutterNotificationType notificationType, DefaultFolderType folder, MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator)
 {
     NotificationManager.SendNotification(notificationType, folder, session, snapshot, frontEndLocator, null);
 }
コード例 #10
0
        private void SaveSharingPartnership(MailboxSession mailboxSession)
        {
            if (mailboxSession == null)
            {
                return;
            }
            IRecipientSession recipientSession = null;
            ADUser            aduser           = null;

            foreach (Permission permission in this.permissions.Values)
            {
                if (permission.Principal.Type == PermissionSecurityPrincipal.SecurityPrincipalType.ExternalUserPrincipal && !permission.Principal.ExternalUser.IsReachUser)
                {
                    if (aduser == null)
                    {
                        recipientSession = mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent);
                        ADRecipient adrecipient = recipientSession.Read(mailboxSession.MailboxOwner.ObjectId);
                        if (adrecipient == null)
                        {
                            throw new ObjectNotFoundException(ServerStrings.ADUserNotFound);
                        }
                        aduser = (adrecipient as ADUser);
                        if (aduser == null)
                        {
                            ExTraceGlobals.StorageTracer.TraceDebug <ADRecipient>((long)this.GetHashCode(), "PermissionTable::SaveSharingParterner. This is not an ADUser so SharingPartnerIdentities doesn't apply. Recipient = {0}.", adrecipient);
                            return;
                        }
                    }
                    string externalId = permission.Principal.ExternalUser.ExternalId;
                    if (!aduser.SharingPartnerIdentities.Contains(externalId))
                    {
                        try
                        {
                            aduser.SharingPartnerIdentities.Add(externalId);
                        }
                        catch (InvalidOperationException ex)
                        {
                            ExTraceGlobals.StorageTracer.TraceError <ADUser, InvalidOperationException>((long)this.GetHashCode(), "PermissionTable::SaveSharingParterner. Failed to add SharingPartnerIdentities on user {0} due to exception {1}.", aduser, ex);
                            throw new InvalidObjectOperationException(new LocalizedString(ex.Message), ex);
                        }
                    }
                }
            }
            if (aduser != null && aduser.SharingPartnerIdentities.Changed)
            {
                try
                {
                    recipientSession.Save(aduser);
                }
                catch (DataValidationException innerException)
                {
                    throw new CorruptDataException(ServerStrings.ExCannotSaveInvalidObject(aduser), innerException);
                }
                catch (DataSourceOperationException ex2)
                {
                    throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "PermissionTable::SaveSharingParterner(): Failed due to directory exception {0}.", new object[]
                    {
                        ex2
                    });
                }
                catch (DataSourceTransientException ex3)
                {
                    throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex3, null, "PermissionTable::SaveSharingParterner(): Failed due to directory exception {0}.", new object[]
                    {
                        ex3
                    });
                }
            }
        }
コード例 #11
0
        public static UserOofSettingsType GetSetting(MailboxSession mailboxSession, ExTimeZone timeZone)
        {
            UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(mailboxSession);

            return(new UserOofSettingsType(userOofSettings, timeZone));
        }
コード例 #12
0
 // Token: 0x06000654 RID: 1620 RVA: 0x00030576 File Offset: 0x0002E776
 public override StoreObjectId GetFolderId(MailboxSession session)
 {
     return(session.GetAuditsFolderId());
 }
コード例 #13
0
 public virtual IActivityLog Bind(MailboxSession mailboxSession)
 {
     return(new AppendOnlyActivityLog(mailboxSession));
 }
コード例 #14
0
 public static G RunQueryOnAllItemsFolder <G>(MailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, object seekToValue, G defaultValue, AllItemsFolderHelper.DoQueryProcessing <G> queryProcessor, ICollection <PropertyDefinition> properties)
 {
     return(AllItemsFolderHelper.RunQueryOnAllItemsFolder <G>(session, supportedSortBy, seekToValue, defaultValue, queryProcessor, properties, ItemQueryType.None));
 }
コード例 #15
0
        private static MailboxSession OpenMailboxSessionAsAdmin(ADUser user, string userAgent)
        {
            ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(user, null);

            return(MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, userAgent));
        }
コード例 #16
0
 public static void SendNotification(ClutterNotificationType notificationType, DefaultFolderType folder, MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator, UserConfiguration inferenceSettings)
 {
     using (NotificationManager notificationManager = new NotificationManager(session, snapshot, frontEndLocator, inferenceSettings))
     {
         notificationManager.SendNotification(notificationType, folder);
         notificationManager.Save();
     }
 }
コード例 #17
0
        private FreeBusyQueryResult InternalGetCalendarData(FreeBusyQuery freeBusyQuery, MailboxSession session)
        {
            FreeBusyViewType freeBusyViewType = FreeBusyViewType.None;

            CalendarEvent[] calendarEventArray = null;
            string          mergedFreeBusy     = null;
            WorkingHours    workingHours       = null;
            EmailAddress    email = freeBusyQuery.Email;
            StoreObjectId   associatedFolderId = freeBusyQuery.RecipientData.AssociatedFolderId;
            StoreObjectId   defaultFolderId    = session.GetDefaultFolderId(DefaultFolderType.Calendar);

            if (defaultFolderId == null)
            {
                return(this.HandleException(email, new NoCalendarException()));
            }
            if (associatedFolderId != null && !associatedFolderId.Equals(defaultFolderId))
            {
                return(this.HandleException(email, new NotDefaultCalendarException()));
            }
            session.ExTimeZone = this.clientContext.TimeZone;
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, DefaultFolderType.Calendar, CalendarQuery.CalendarFolderQueryProps))
            {
                TimeSpan t = this.deadline - DateTime.UtcNow;
                if (t <= TimeSpan.Zero)
                {
                    return(this.HandleException(email, new TimeoutExpiredException("Determine-Allowed-Access")));
                }
                FreeBusyPermissionLevel freeBusyPermissionLevel = FreeBusyPermission.DetermineAllowedAccess(this.clientContext, session, calendarFolder, freeBusyQuery, this.defaultFreeBusyOnly);
                CalendarQuery.CalendarViewTracer.TraceDebug((long)this.GetHashCode(), "{0}: AccessCheck returned {1} for user {2} on mailbox {3}", new object[]
                {
                    TraceContext.Get(),
                    freeBusyPermissionLevel,
                    this.clientContext,
                    email
                });
                if (freeBusyPermissionLevel == FreeBusyPermissionLevel.None)
                {
                    CalendarQuery.CalendarViewTracer.TraceDebug <object, EmailAddress>((long)this.GetHashCode(), "{0}: No mailbox data will be returned for mailbox {1} since the granted access level to caller is None.", TraceContext.Get(), email);
                    return(new FreeBusyQueryResult(new NoFreeBusyAccessException(44348U)));
                }
                t = this.deadline - DateTime.UtcNow;
                if (t <= TimeSpan.Zero)
                {
                    return(this.HandleException(email, new TimeoutExpiredException("Get-Calendar-View")));
                }
                freeBusyViewType = CalendarQuery.GetReturnView(this.requestedFreeBusyView.RequestedView, freeBusyPermissionLevel);
                ExDateTime windowStart = new ExDateTime(this.clientContext.TimeZone, this.requestedFreeBusyView.TimeWindow.StartTime);
                ExDateTime windowEnd   = new ExDateTime(this.clientContext.TimeZone, this.requestedFreeBusyView.TimeWindow.EndTime);
                try
                {
                    calendarEventArray = InternalCalendarQuery.GetCalendarEvents(email, calendarFolder, windowStart, windowEnd, freeBusyViewType, freeBusyPermissionLevel == FreeBusyPermissionLevel.Owner, this.clientContext.RequestSchemaVersion);
                }
                catch (ResultSetTooBigException e)
                {
                    return(this.HandleException(email, e));
                }
                if (FreeBusyViewOptions.IsMerged(freeBusyViewType))
                {
                    t = this.deadline - DateTime.UtcNow;
                    if (t <= TimeSpan.Zero)
                    {
                        return(this.HandleException(email, new TimeoutExpiredException("Generate-Merged-FreeBusy")));
                    }
                    int mergedFreeBusyIntervalInMinutes = this.requestedFreeBusyView.MergedFreeBusyIntervalInMinutes;
                    mergedFreeBusy = MergedFreeBusy.GenerateMergedFreeBusyString(this.clientContext.TimeZone, mergedFreeBusyIntervalInMinutes, windowStart, windowEnd, calendarEventArray, false, null, this.clientContext.RequestSchemaVersion);
                }
                t = this.deadline - DateTime.UtcNow;
                if (t <= TimeSpan.Zero)
                {
                    return(this.HandleException(email, new TimeoutExpiredException("Getting-Work-Hours")));
                }
                workingHours = this.GetWorkingHours(email, session, calendarFolder);
            }
            return(new FreeBusyQueryResult(freeBusyViewType, calendarEventArray, mergedFreeBusy, workingHours));
        }
コード例 #18
0
        internal Exception PublishGroupPost(CoreItem coreItem, string groupName, string groupId)
        {
            Exception         ex             = null;
            MailboxSession    mailboxSession = coreItem.Session as MailboxSession;
            IExtensibleLogger logger         = WorkingSetPublisherDiagnosticsFrameFactory.Default.CreateLogger(mailboxSession.MailboxGuid, mailboxSession.OrganizationId);
            IWorkingSetPublisherPerformanceTracker workingSetPublisherPerformanceTracker = WorkingSetPublisherDiagnosticsFrameFactory.Default.CreatePerformanceTracker(mailboxSession);

            using (WorkingSetPublisherDiagnosticsFrameFactory.Default.CreateDiagnosticsFrame("XSO", "PublishGroupPost", logger, workingSetPublisherPerformanceTracker))
            {
                try
                {
                    this.EnsureGroupMailboxData(mailboxSession);
                    if (this.groupsCache[mailboxSession.MailboxGuid].TargetUsers.Count == 0)
                    {
                        WorkingSetPublisher.Tracer.TraceDebug((long)this.GetHashCode(), "WorkingSetPublisher.PublishGroupPost: Skipping publishing as there are no users to publish to");
                        return(null);
                    }
                    coreItem.PropertyBag.Load(CoreObjectSchema.AllPropertiesOnStore);
                    object      obj         = coreItem.PropertyBag.TryGetProperty(ItemSchema.From);
                    Participant participant = obj as Participant;
                    if (participant != null)
                    {
                        workingSetPublisherPerformanceTracker.OriginalMessageSender = (participant.EmailAddress ?? string.Empty);
                        workingSetPublisherPerformanceTracker.OriginalMessageSenderRecipientType = ((participant.Origin != null) ? participant.Origin.ToString() : string.Empty);
                        workingSetPublisherPerformanceTracker.OriginalMessageClass      = coreItem.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);
                        workingSetPublisherPerformanceTracker.OriginalMessageId         = ((coreItem.Id != null) ? coreItem.Id.ToBase64String() : string.Empty);
                        workingSetPublisherPerformanceTracker.OriginalInternetMessageId = coreItem.PropertyBag.GetValueOrDefault <string>(ItemSchema.InternetMessageId, string.Empty);
                    }
                    workingSetPublisherPerformanceTracker.ParticipantsInOriginalMessage = coreItem.Recipients.Count;
                    Participant[] participantsOnOriginalMessage = null;
                    using (MessageItem messageItem = this.CreateMessageItemForPublishing(coreItem, out participantsOnOriginalMessage, workingSetPublisherPerformanceTracker))
                    {
                        List <string> targetUsers = this.GetTargetUsers(messageItem, participantsOnOriginalMessage, workingSetPublisherPerformanceTracker);
                        workingSetPublisherPerformanceTracker.HasWorkingSetUser = (targetUsers.Count > 0);
                        if (targetUsers.Count == 0)
                        {
                            WorkingSetPublisher.Tracer.TraceDebug((long)this.GetHashCode(), "WorkingSetPublisher.PublishGroupPost: Skipping publishing as there are no additional users to publish to");
                            return(null);
                        }
                        Dictionary <string, object> signalProperties = new Dictionary <string, object>
                        {
                            {
                                "WorkingSetSourcePartition",
                                groupName
                            },
                            {
                                "WorkingSetSourcePartitionInternal",
                                groupId
                            }
                        };
                        workingSetPublisherPerformanceTracker.PublishedMessageId          = ((messageItem.Id != null) ? messageItem.Id.ToBase64String() : string.Empty);
                        workingSetPublisherPerformanceTracker.PublishedIntnernetMessageId = (messageItem.InternetMessageId ?? string.Empty);
                        ex = this.PublishItemAdd(messageItem, targetUsers, "ExchangePinnedGroup", signalProperties);
                    }
                }
                catch (StoragePermanentException ex2)
                {
                    ex = ex2;
                    this.TraceAndLogError(logger, "PublishGroupPost", string.Format("WorkingSetPublisher.PublishGroupPost: Publishing failed failed with store permanent exception: {0}", ex2));
                    workingSetPublisherPerformanceTracker.Exception = ex.ToString();
                }
                catch (StorageTransientException ex3)
                {
                    ex = ex3;
                    this.TraceAndLogError(logger, "PublishGroupPost", string.Format("WorkingSetPublisher.PublishGroupPost: Publishing failed failed with store transient exception: {0}", ex3));
                    workingSetPublisherPerformanceTracker.Exception = ex.ToString();
                }
                catch (Exception ex4)
                {
                    this.TraceAndLogError(logger, "PublishGroupPost", string.Format("WorkingSetPublisher.PublishGroupPost: Publishing failed failed with unexpected exception: {0}", ex4));
                    workingSetPublisherPerformanceTracker.Exception = ex4.ToString();
                    throw;
                }
            }
            return(ex);
        }
コード例 #19
0
        private StoreSession OpenMailboxSession(StoreMailboxData mailbox)
        {
            Guid          activityId       = (ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value : Guid.Empty;
            AssistantBase assistant        = this.Assistant as AssistantBase;
            string        nonLocalizedName = this.Assistant.NonLocalizedName;
            Guid          mailboxGuid      = mailbox.MailboxGuid;
            StoreSession  result;

            try
            {
                ExchangePrincipal exchangePrincipal;
                if (mailbox.TenantPartitionHint != null)
                {
                    ADSessionSettings adSettings = ADSessionSettings.FromTenantPartitionHint(mailbox.TenantPartitionHint);
                    exchangePrincipal = ExchangePrincipal.FromLocalServerMailboxGuid(adSettings, this.DatabaseInfo.Guid, mailbox.Guid);
                }
                else
                {
                    exchangePrincipal = ExchangePrincipal.FromMailboxData(mailbox.Guid, this.DatabaseInfo.Guid, mailbox.OrganizationId ?? OrganizationId.ForestWideOrgId, Array <CultureInfo> .Empty);
                }
                if (mailbox.IsPublicFolderMailbox)
                {
                    StoreSession storeSession = PublicFolderSession.OpenAsAdmin(null, exchangePrincipal, null, CultureInfo.InstalledUICulture, string.Format("{0};Action={1}", "Client=TBA", this.Assistant.GetType().Name), null);
                    AssistantsLog.LogMailboxSucceedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, mailboxGuid, mailbox.DisplayName, this);
                    result = storeSession;
                }
                else
                {
                    bool           flag     = false;
                    MailboxSession mailbox2 = this.DatabaseInfo.GetMailbox(exchangePrincipal, ClientType.TimeBased, this.Assistant.GetType().Name);
                    try
                    {
                        mailbox2.ReconstructExchangePrincipal();
                        mailbox2.ExTimeZone = ExTimeZone.CurrentTimeZone;
                        flag = true;
                        AssistantsLog.LogMailboxSucceedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, mailboxGuid, mailbox.DisplayName, this);
                        result = mailbox2;
                    }
                    finally
                    {
                        if (!flag)
                        {
                            mailbox2.Dispose();
                        }
                    }
                }
            }
            catch (ObjectNotFoundException ex)
            {
                string text    = "MailboxNotFound";
                string message = string.Format("{0}: {1}", this, text);
                string value   = string.Format("{0}:{1}", text, mailbox.MailboxGuid);
                ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message);
                AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex, mailboxGuid, mailbox.DisplayName, this);
                throw new SkipException(new LocalizedString(value), ex);
            }
            catch (StorageTransientException ex2)
            {
                string message2 = string.Format("{0}: Could not open mailbox store session due to storage transient error: {1}", this, ex2.Message);
                ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message2);
                AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex2, mailboxGuid, mailbox.DisplayName, this);
                Interlocked.Increment(ref this.mailboxesFailedToOpenStoreSessionCount);
                throw;
            }
            catch (Exception ex3)
            {
                string message3 = string.Format("{0}: Could not open mailbox store session due to error: {1}", this, ex3.Message);
                ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message3);
                AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex3, mailboxGuid, mailbox.DisplayName, this);
                Interlocked.Increment(ref this.mailboxesFailedToOpenStoreSessionCount);
                throw;
            }
            return(result);
        }
コード例 #20
0
 public MailboxAuditLogSearchDataProvider(MailboxSession mailboxSession) : base(mailboxSession, MailboxAuditLogSearchDataProvider.MailboxAuditLogSearchSetting)
 {
 }
コード例 #21
0
ファイル: GlobalInfo.cs プロジェクト: YHZX2013/exchange_diff
        public static GlobalInfo LoadFromMailbox(MailboxSession mailboxSession, SyncStateStorage syncStateStorage, ProtocolLogger protocolLogger, out bool updateUserHasPartnership)
        {
            if (mailboxSession == null)
            {
                throw new ArgumentNullException("mailboxSession");
            }
            if (syncStateStorage == null)
            {
                throw new ArgumentNullException("syncStateStorage");
            }
            updateUserHasPartnership = false;
            CustomSyncState customSyncState         = null;
            GlobalInfo      globalInfo              = null;
            bool            isDirty                 = false;
            bool            hasNewSyncData          = false;
            bool            hasNewAutdData          = false;
            bool            isSyncStateJustUpgraded = false;
            bool            flag = false;
            GlobalInfo      result;

            try
            {
                GlobalSyncStateInfo syncStateInfo = new GlobalSyncStateInfo();
                customSyncState = syncStateStorage.GetCustomSyncState(syncStateInfo, GlobalInfo.ExtraGlobalInfoPropertiesToFetch);
                if (customSyncState == null)
                {
                    isDirty = true;
                    using (CustomSyncState customSyncState2 = syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                    {
                        if (customSyncState2 == null)
                        {
                            updateUserHasPartnership = true;
                            syncStateStorage.DeleteAllSyncStates();
                        }
                    }
                    customSyncState = syncStateStorage.CreateCustomSyncState(syncStateInfo);
                    isDirty         = true;
                }
                else
                {
                    try
                    {
                        object obj = customSyncState.StoreObject.TryGetProperty(AirSyncStateSchema.LastSyncAttemptTime);
                        hasNewSyncData = (obj != null && !(obj is PropertyError));
                    }
                    catch (Exception arg)
                    {
                        AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, null, "[GlobalInfo.LoadFromMailbox] Encountered exception when checking for new syncStatus properties.  Exception: {0}", arg);
                    }
                    try
                    {
                        object obj2 = customSyncState.StoreObject.TryGetProperty(AirSyncStateSchema.LastPingHeartbeatInterval);
                        hasNewAutdData = (obj2 != null && !(obj2 is PropertyError));
                    }
                    catch (Exception arg2)
                    {
                        AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, null, "[GlobalInfo.LoadFromMailbox] Encountered exception when checking for new syncStatus properties.  Exception: {0}", arg2);
                    }
                    if (customSyncState.BackendVersion != null && customSyncState.BackendVersion.Value != customSyncState.Version)
                    {
                        isDirty = true;
                        isSyncStateJustUpgraded = true;
                        if (protocolLogger != null)
                        {
                            protocolLogger.SetValue(ProtocolLoggerData.Ssu, "2007");
                        }
                    }
                }
                globalInfo                         = new GlobalInfo(customSyncState);
                globalInfo.IsDirty                 = isDirty;
                globalInfo.HasNewSyncData          = hasNewSyncData;
                globalInfo.HasNewAutdData          = hasNewAutdData;
                globalInfo.IsSyncStateJustUpgraded = isSyncStateJustUpgraded;
                if (Command.CurrentCommand != null)
                {
                    globalInfo.WriteNewSyncData = Command.CurrentCommand.User.Features.IsEnabled(EasFeature.SyncStatusOnGlobalInfo);
                }
                flag   = true;
                result = globalInfo;
            }
            finally
            {
                if (!flag)
                {
                    if (globalInfo != null)
                    {
                        globalInfo.Dispose();
                    }
                    else if (customSyncState != null)
                    {
                        customSyncState.Dispose();
                    }
                }
            }
            return(result);
        }
コード例 #22
0
 public SharingSubscriptionManager(MailboxSession mailboxSession) : base(mailboxSession, "IPM.ExternalSharingSubscription", SharingSubscriptionManager.ItemProperties)
 {
 }
コード例 #23
0
 private DefaultFolderManager(MailboxSession session)
 {
     this.session        = session;
     this.defaultFolders = new DefaultFolder[DefaultFolderInfo.DefaultFolderTypeCount];
 }
コード例 #24
0
ファイル: Utils.cs プロジェクト: YHZX2013/exchange_diff
        public static bool IsTeamMailbox(StoreSession session)
        {
            MailboxSession mailboxSession = session as MailboxSession;

            return(mailboxSession != null && mailboxSession.MailboxOwner.RecipientTypeDetails == RecipientTypeDetails.TeamMailbox);
        }
コード例 #25
0
        internal static DefaultFolderManager Create(MailboxSession session, OpenMailboxSessionFlags openFlags, IList <DefaultFolderType> foldersToInit)
        {
            DefaultFolderManager defaultFolderManager = new DefaultFolderManager(session);
            DefaultFolderContext defaultFolderContext = new DefaultFolderContext(session, defaultFolderManager.defaultFolders);

            defaultFolderManager.context = defaultFolderContext;
            if ((openFlags & OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization) == OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization)
            {
                defaultFolderContext.DeferFolderIdInit = true;
            }
            if ((openFlags & OpenMailboxSessionFlags.IgnoreForcedFolderInit) == OpenMailboxSessionFlags.IgnoreForcedFolderInit)
            {
                defaultFolderContext.IgnoreForcedFolderInit = true;
            }
            if (defaultFolderContext.Session.SharedDataManager.DefaultFoldersInitialized)
            {
                defaultFolderManager.CacheDefaultFoldersFromSharedDataManager(defaultFolderContext);
                defaultFolderContext.DoneDefaultFolderInitialization();
                return(defaultFolderManager);
            }
            try
            {
                if ((openFlags & OpenMailboxSessionFlags.SuppressFolderIdPrefetch) == OpenMailboxSessionFlags.None)
                {
                    defaultFolderContext.FolderDataDictionary = defaultFolderManager.ReadFolderData();
                }
                else if (session.Capabilities.CanCreateDefaultFolders)
                {
                    string      inboxDisplayName = null;
                    CultureInfo stampedCulture   = session.Capabilities.CanHaveCulture ? session.PreferedCulture : CultureInfo.InvariantCulture;
                    if (session.LogonType != LogonType.Delegated)
                    {
                        object thisObject = null;
                        bool   flag       = false;
                        byte[] inboxFolderEntryId;
                        try
                        {
                            if (session != null)
                            {
                                session.BeginMapiCall();
                                session.BeginServerHealthCall();
                                flag = true;
                            }
                            if (StorageGlobals.MapiTestHookBeforeCall != null)
                            {
                                StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                            }
                            inboxFolderEntryId = session.Mailbox.MapiStore.GetInboxFolderEntryId();
                        }
                        catch (MapiPermanentException ex)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]),
                                ex
                            });
                        }
                        catch (MapiRetryableException ex2)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]),
                                ex2
                            });
                        }
                        finally
                        {
                            try
                            {
                                if (session != null)
                                {
                                    session.EndMapiCall();
                                    if (flag)
                                    {
                                        session.EndServerHealthCall();
                                    }
                                }
                            }
                            finally
                            {
                                if (StorageGlobals.MapiTestHookAfterCall != null)
                                {
                                    StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                                }
                            }
                        }
                        if (IdConverter.IsFolderId(inboxFolderEntryId))
                        {
                            StoreObjectId inboxId = StoreObjectId.FromProviderSpecificId(inboxFolderEntryId);
                            DefaultFolderManager.TryGetDefaultFolderCulture(session, inboxId, out stampedCulture, out inboxDisplayName);
                        }
                    }
                    defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = defaultFolderManager.GetBestCulture(stampedCulture, inboxDisplayName, session);
                }
                else
                {
                    defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = CultureInfo.InvariantCulture;
                }
                defaultFolderManager.CacheDefaultFolders(defaultFolderContext, foldersToInit);
                defaultFolderManager.ValidateDefaultFolderSet(defaultFolderContext);
            }
            finally
            {
                defaultFolderContext.DoneDefaultFolderInitialization();
            }
            return(defaultFolderManager);
        }
コード例 #26
0
ファイル: Utils.cs プロジェクト: YHZX2013/exchange_diff
        public static LinkedItemProps FindFolderBySharePointUri(MailboxSession session, Folder rootFolder, Uri sharePointUri, PerformanceCounter performanceCounter)
        {
            performanceCounter.Start(OperationType.FolderLookupByUri);
            string text = rootFolder.PropertyBag.GetValueOrDefault <string>(FolderSchema.LinkedUrl, null);

            if (!string.IsNullOrEmpty(text))
            {
                Uri uri = null;
                try
                {
                    uri = new Uri(text);
                }
                catch (UriFormatException)
                {
                }
                if (uri != null && UriComparer.IsEqual(uri, sharePointUri))
                {
                    performanceCounter.Stop(OperationType.FolderLookupByUri, 1);
                    return(new LinkedItemProps(rootFolder.Id.ObjectId, rootFolder.ParentId));
                }
            }
            using (QueryResult queryResult = rootFolder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, new PropertyDefinition[]
            {
                FolderSchema.LinkedUrl,
                FolderSchema.Id,
                StoreObjectSchema.ParentItemId
            }))
            {
                object[][] array = null;
                int        i;
                for (;;)
                {
                    array = queryResult.GetRows(10000);
                    for (i = 0; i < array.Length; i++)
                    {
                        text = (array[i][0] as string);
                        if (!string.IsNullOrEmpty(text))
                        {
                            Uri x = null;
                            try
                            {
                                x = new Uri(text);
                            }
                            catch (UriFormatException)
                            {
                                goto IL_FF;
                            }
                            if (UriComparer.IsEqual(x, sharePointUri))
                            {
                                goto Block_11;
                            }
                        }
                        IL_FF :;
                    }
                    if (array.Length == 0)
                    {
                        goto Block_13;
                    }
                }
Block_11:
                performanceCounter.Stop(OperationType.FolderLookupByUri, 1);
                return(new LinkedItemProps(((VersionedId)array[i][1]).ObjectId, (StoreObjectId)array[i][2]));

                Block_13 :;
            }
            performanceCounter.Stop(OperationType.FolderLookupByUri, 1);
            return(null);
        }
コード例 #27
0
 public virtual MdbPeopleModelDataBinder CreateInstance(MailboxSession session)
 {
     return(new MdbPeopleModelDataBinder(session));
 }
コード例 #28
0
 internal abstract void ContactLinkingOperation(MailboxSession mailboxSession);
コード例 #29
0
 public XsoDictionaryDataProvider(MailboxSession session) : base(session)
 {
 }
コード例 #30
0
 internal virtual GetAttachmentDataProviderItemsResponse GetItems(AttachmentItemsPagingDetails paging, AttachmentDataProviderScope scope, MailboxSession mailboxSession)
 {
     throw new NotImplementedException();
 }