private static void CreateUserConfiguration(StoreRetentionPolicyTagHelper tagHelper)
		{
			byte[] xmlData = MrmFaiFormatter.Serialize(tagHelper.TagData, tagHelper.defaultArchiveTagData, tagHelper.deletedTags, tagHelper.retentionHoldData, tagHelper.fullCrawlRequired, tagHelper.exchangePrincipal);
			CreateUserConfigurationType createUserConfiguration = new CreateUserConfigurationType
			{
				UserConfiguration = new UserConfigurationType
				{
					UserConfigurationName = new UserConfigurationNameType
					{
						Name = "MRM",
						Item = new DistinguishedFolderIdType
						{
							Id = DistinguishedFolderIdNameType.inbox
						}
					},
					XmlData = xmlData
				}
			};
			StoreRetentionPolicyTagHelper.CallEwsWithRetries(() => tagHelper.serviceBinding.CreateUserConfiguration(createUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex)
			{
				if (responseMessage.ResponseClass == ResponseClassType.Success)
				{
					ExTraceGlobals.ELCTracer.TraceDebug(0L, "Successfully created MRM user configuration");
					return true;
				}
				ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration was not created");
				return false;
			}, tagHelper);
		}
Esempio n. 2
0
        // Token: 0x060003C2 RID: 962 RVA: 0x0001A7F0 File Offset: 0x000189F0
        private bool FaiExists(MailboxSession mailboxSession)
        {
            UserConfiguration userConfiguration = ElcMailboxHelper.OpenFaiMessage(mailboxSession, "MRM", true);

            if (userConfiguration == null)
            {
                ElcSubAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "FAI cannot be found or created.");
                return(false);
            }
            Dictionary <Guid, StoreTagData> dictionary = null;

            try
            {
                dictionary = MrmFaiFormatter.Deserialize(userConfiguration, mailboxSession.MailboxOwner);
            }
            catch (ObjectNotFoundException arg)
            {
                ElcSubAssistant.Tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "Deserialize of MRM FAI message failed because it could not be found. Exception: {0}", arg);
                return(false);
            }
            finally
            {
                if (userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
            }
            return(dictionary != null && dictionary.Count > 0);
        }
 // Token: 0x0600041E RID: 1054 RVA: 0x0001D62E File Offset: 0x0001B82E
 internal byte[] GetCompactDefaultPolicy()
 {
     if (this.compactDefaultPolicy == null)
     {
         this.compactDefaultPolicy = MrmFaiFormatter.SerializeDefaultPolicy(this.storeTagDictionary, base.MailboxSession.MailboxOwner);
     }
     return(this.compactDefaultPolicy);
 }
		internal void SaveToXSO()
		{
			if (this.configItem != null)
			{
				MrmFaiFormatter.Serialize(this.TagData, this.defaultArchiveTagData, this.deletedTags, this.retentionHoldData, this.configItem, this.fullCrawlRequired, this.mailboxSession.MailboxOwner);
				this.configItem.Save();
				return;
			}
			throw new ElcUserConfigurationException(Strings.ElcUserConfigurationConfigurationItemNotAvailable);
		}
 // Token: 0x06000423 RID: 1059 RVA: 0x0001D818 File Offset: 0x0001BA18
 private bool GetStoreData()
 {
     if (this.configItem == null)
     {
         this.EnsureUserConfigurationIsValid();
     }
     try
     {
         this.storeTagDictionary = MrmFaiFormatter.Deserialize(this.configItem, base.MailboxSession.MailboxOwner, out this.deletedTags, out this.fullCrawlRequired);
         if (this.IsArchiveMailUser)
         {
             foreach (StoreTagData storeTagData in this.storeTagDictionary.Values)
             {
                 bool flag = ElcMailboxHelper.IsArchiveTag(storeTagData, false);
                 if (storeTagData.Tag.Type == ElcFolderType.All && !flag)
                 {
                     foreach (ContentSetting contentSetting in storeTagData.ContentSettings.Values)
                     {
                         if (contentSetting.MessageClass.Equals(ElcMessageClass.AllMailboxContent, StringComparison.CurrentCultureIgnoreCase))
                         {
                             this.defaultAdTag = storeTagData.Tag.RetentionId;
                             break;
                         }
                         if (contentSetting.MessageClass.Equals(ElcMessageClass.VoiceMail, StringComparison.CurrentCultureIgnoreCase))
                         {
                             this.defaultVmAdTag = storeTagData.Tag.RetentionId;
                             break;
                         }
                     }
                 }
             }
             this.defaultContentSettingList = new List <ElcPolicySettings>();
             if (!this.defaultAdTag.Equals(Guid.Empty))
             {
                 foreach (ContentSetting elcContentSetting in this.storeTagDictionary[this.defaultAdTag].ContentSettings.Values)
                 {
                     ElcPolicySettings.ParseContentSettings(this.defaultContentSettingList, elcContentSetting);
                 }
             }
             if (!this.defaultVmAdTag.Equals(Guid.Empty))
             {
                 foreach (ContentSetting elcContentSetting2 in this.storeTagDictionary[this.defaultVmAdTag].ContentSettings.Values)
                 {
                     ElcPolicySettings.ParseContentSettings(this.defaultContentSettingList, elcContentSetting2);
                 }
             }
         }
     }
     catch (ObjectNotFoundException arg)
     {
         ElcUserInformation.Tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "Deserialize of MRM FAI message failed because it could not be found. Exception: {0}", arg);
         return(false);
     }
     return(true);
 }
		private static void FetchRetentionPolicyTagDataFromService(StoreRetentionPolicyTagHelper srpth)
		{
			StoreRetentionPolicyTagHelper.InitializeServiceBinding(srpth);
			if (srpth.serviceBinding != null)
			{
				GetUserConfigurationType getUserConfiguration = new GetUserConfigurationType
				{
					UserConfigurationName = new UserConfigurationNameType
					{
						Name = "MRM",
						Item = new DistinguishedFolderIdType
						{
							Id = DistinguishedFolderIdNameType.inbox
						}
					},
					UserConfigurationProperties = (UserConfigurationPropertyType.Dictionary | UserConfigurationPropertyType.XmlData | UserConfigurationPropertyType.BinaryData)
				};
				StoreRetentionPolicyTagHelper.CallEwsWithRetries(() => srpth.serviceBinding.GetUserConfiguration(getUserConfiguration), delegate(ResponseMessageType responseMessage, int messageIndex)
				{
					GetUserConfigurationResponseMessageType getUserConfigurationResponseMessageType = responseMessage as GetUserConfigurationResponseMessageType;
					if (getUserConfigurationResponseMessageType.ResponseClass == ResponseClassType.Success && getUserConfigurationResponseMessageType.UserConfiguration != null)
					{
						if (getUserConfigurationResponseMessageType.UserConfiguration.XmlData != null)
						{
							ExTraceGlobals.ELCTracer.TraceDebug(0L, "Acquired MRM user configuration.");
							srpth.TagData = MrmFaiFormatter.Deserialize(getUserConfigurationResponseMessageType.UserConfiguration.XmlData, srpth.exchangePrincipal, out srpth.deletedTags, out srpth.retentionHoldData, true, out srpth.defaultArchiveTagData, out srpth.fullCrawlRequired);
							srpth.configItemExists = true;
						}
						else
						{
							ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration is null");
							srpth.TagData = new Dictionary<Guid, StoreTagData>();
							srpth.configItemExists = false;
						}
						return true;
					}
					if (getUserConfigurationResponseMessageType.ResponseClass == ResponseClassType.Error && getUserConfigurationResponseMessageType.ResponseCode == ResponseCodeType.ErrorItemNotFound)
					{
						ExTraceGlobals.ELCTracer.TraceDebug(0L, "MRM user configuration not found");
						srpth.TagData = new Dictionary<Guid, StoreTagData>();
						srpth.configItemExists = false;
						return true;
					}
					ExTraceGlobals.ELCTracer.TraceDebug(0L, "Getting MRM user configuration failed");
					return false;
				}, srpth);
				return;
			}
			throw new ElcUserConfigurationException(Strings.ElcUserConfigurationServiceBindingNotAvailable);
		}
		private static void FetchRetentionPolcyTagDataFromXSO(StoreRetentionPolicyTagHelper srpth)
		{
			if (srpth.exchangePrincipal == null)
			{
				ExTraceGlobals.ELCTracer.TraceDebug(0L, "Cannot fetch retention policy tag data because Exchange principal is not available.");
				return;
			}
			srpth.mailboxSession = MailboxSession.OpenAsAdmin(srpth.exchangePrincipal, CultureInfo.InvariantCulture, "Client=Management;Action=Get-/Set-RetentionPolicyTag");
			srpth.configItem = ElcMailboxHelper.OpenFaiMessage(srpth.mailboxSession, "MRM", true);
			if (srpth.configItem != null)
			{
				srpth.TagData = MrmFaiFormatter.Deserialize(srpth.configItem, srpth.exchangePrincipal, out srpth.deletedTags, out srpth.retentionHoldData, true, out srpth.defaultArchiveTagData, out srpth.fullCrawlRequired);
				return;
			}
			srpth.TagData = new Dictionary<Guid, StoreTagData>();
		}
        // Token: 0x06000417 RID: 1047 RVA: 0x0001CE4C File Offset: 0x0001B04C
        internal bool SaveConfigItem(IArchiveProcessor archiveProcessor)
        {
            bool      result = false;
            Exception arg    = null;

            try
            {
                MrmFaiFormatter.Serialize(this.storeTagDictionary, this.storeDefaultArchiveTagDictionary, this.deletedTags, new RetentionHoldData(base.SuspendExpiration, base.ADUser.RetentionComment, base.ADUser.RetentionUrl), this.configItem, false, base.MailboxSession.MailboxOwner);
                this.configItem.Save();
                IMailboxInfo archiveMailbox = base.MailboxSession.MailboxOwner.GetArchiveMailbox();
                if (!base.MailboxSession.MailboxOwner.MailboxInfo.IsArchive && archiveProcessor != null && archiveMailbox != null && archiveMailbox.IsRemote)
                {
                    CloudArchiveProcessor cloudArchiveProcessor = archiveProcessor as CloudArchiveProcessor;
                    if (cloudArchiveProcessor != null && cloudArchiveProcessor.ArchiveEwsClient != null)
                    {
                        byte[] xmlData = MrmFaiFormatter.Serialize(this.storeTagDictionary, this.storeDefaultArchiveTagDictionary, null, new RetentionHoldData(base.SuspendExpiration, base.ADUser.RetentionComment, base.ADUser.RetentionUrl), this.fullCrawlRequired, base.MailboxSession.MailboxOwner);
                        if (!cloudArchiveProcessor.SaveConfigItemInArchive(xmlData))
                        {
                            ElcUserInformation.Tracer.TraceError((long)this.GetHashCode(), "The MRM FAI message could not be saved to the cross-premise archive");
                            return(false);
                        }
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                if (ex is ObjectNotFoundException || ex is ObjectExistedException || ex is SaveConflictException || ex is StorageTransientException || ex is StoragePermanentException)
                {
                    result = false;
                    ElcUserInformation.Tracer.TraceDebug <IExchangePrincipal, MailboxSession, Exception>((long)this.GetHashCode(), "The MRM FAI message could not be saved. Mailbox Owner {0}, Mailbox Session {1}. Exception: {2}", base.MailboxSession.MailboxOwner, base.MailboxSession, arg);
                    throw new TransientMailboxException(ex);
                }
                throw;
            }
            return(result);
        }
Esempio n. 9
0
        // Token: 0x060004E5 RID: 1253 RVA: 0x000252C0 File Offset: 0x000234C0
        internal void LoadStoreTagDataFromStore(MailboxSession mailboxSession)
        {
            this.ResetState();
            StoreId   defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
            Exception ex = null;

            this.underRetentionPolicy       = false;
            this.storeTagDictionary         = null;
            this.folderTagDictionary        = null;
            this.folderArchiveTagDictionary = null;
            this.itemClassToPolicyMapping   = null;
            try
            {
                using (UserConfiguration folderConfiguration = mailboxSession.UserConfigurationManager.GetFolderConfiguration("MRM", UserConfigurationTypes.Stream | UserConfigurationTypes.XML | UserConfigurationTypes.Dictionary, defaultFolderId))
                {
                    this.storeTagDictionary               = MrmFaiFormatter.Deserialize(folderConfiguration, mailboxSession.MailboxOwner);
                    this.haveCheckedForDefault            = false;
                    this.checkedForDefaultForMessageClass = false;
                    this.defaultTag   = null;
                    this.defaultVmTag = null;
                    StoreTagData storeTagData = new StoreTagData();
                    storeTagData.Tag      = new RetentionTag();
                    storeTagData.Tag.Guid = PolicyTagHelper.SystemCleanupTagGuid;
                    this.storeTagDictionary[PolicyTagHelper.SystemCleanupTagGuid] = storeTagData;
                    this.defaultContentSettingList = new List <ElcPolicySettings>();
                    foreach (StoreTagData storeTagData2 in this.storeTagDictionary.Values)
                    {
                        if (storeTagData2.Tag.Type == ElcFolderType.All)
                        {
                            foreach (ContentSetting elcContentSetting in storeTagData2.ContentSettings.Values)
                            {
                                ElcPolicySettings.ParseContentSettings(this.defaultContentSettingList, elcContentSetting);
                            }
                        }
                    }
                    this.folderTypeDictionary       = new Dictionary <StoreObjectId, DefaultFolderType>();
                    this.folderTagDictionary        = new Dictionary <StoreObjectId, Guid>();
                    this.folderArchiveTagDictionary = new Dictionary <StoreObjectId, Guid>();
                    this.itemClassToPolicyMapping   = new Dictionary <string, ContentSetting>();
                    this.underRetentionPolicy       = true;
                    if (this.rootFolderId == null)
                    {
                        StoreObjectId defaultFolderId2 = mailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
                        if (defaultFolderId2 != null)
                        {
                            this.rootFolderId = defaultFolderId2.ProviderLevelItemId;
                        }
                    }
                    if (this.sentItemsId == null)
                    {
                        StoreObjectId defaultFolderId3 = mailboxSession.GetDefaultFolderId(DefaultFolderType.SentItems);
                        if (defaultFolderId3 != null)
                        {
                            this.sentItemsId = defaultFolderId3.ProviderLevelItemId;
                        }
                    }
                    if (this.deletedItemsId == null)
                    {
                        StoreObjectId defaultFolderId4 = mailboxSession.GetDefaultFolderId(DefaultFolderType.DeletedItems);
                        if (defaultFolderId4 != null)
                        {
                            this.deletedItemsId = defaultFolderId4.ProviderLevelItemId;
                        }
                    }
                    this.CacheFolderIdsToSkip(mailboxSession);
                }
            }
            catch (ObjectNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (CorruptDataException ex3)
            {
                ex = ex3;
            }
            catch (StorageTransientException ex4)
            {
                ex = ex4;
            }
            catch (StoragePermanentException ex5)
            {
                ex = ex5;
            }
            if (ex != null)
            {
                UserRetentionPolicyCache.Tracer.TraceDebug <UserRetentionPolicyCache, Exception>((long)this.GetHashCode(), "{0}: Config message with store settings is missing or corrupt. Recreate it. Exception: {1}", this, ex);
                this.underRetentionPolicy       = false;
                this.storeTagDictionary         = null;
                this.folderTagDictionary        = null;
                this.folderArchiveTagDictionary = null;
                this.itemClassToPolicyMapping   = null;
            }
        }