Пример #1
0
        internal static void ValidateOverrideDuration(EnhancedTimeSpan?duration)
        {
            EnhancedTimeSpan zero = EnhancedTimeSpan.Zero;
            EnhancedTimeSpan t    = EnhancedTimeSpan.FromDays(365.0);

            if ((duration != null && duration.Value <= zero) || (duration != null && duration.Value > t))
            {
                throw new InvalidDurationException(zero.ToString(), t.ToString());
            }
        }
Пример #2
0
 protected override void InternalValidate()
 {
     base.InternalValidate();
     this.helper.ParseAndValidateIdentity(this.Identity, false);
     if (base.Fields.IsModified("ApplyVersion"))
     {
         MonitoringOverrideHelpers.ValidateApplyVersion(this.ApplyVersion);
     }
     if (base.Fields.IsModified("Duration"))
     {
         MonitoringOverrideHelpers.ValidateOverrideDuration(this.Duration);
         return;
     }
     this.Duration = new EnhancedTimeSpan?(EnhancedTimeSpan.FromDays(365.0));
 }
Пример #3
0
 protected override void InternalValidate()
 {
     if (this.Duration != null)
     {
         EnhancedTimeSpan zero = EnhancedTimeSpan.Zero;
         if (this.Duration.Value <= zero)
         {
             base.WriteError(new ArgumentException(Strings.DurationShouldBeGreaterThanZero(zero.ToString()), "Duration"), ErrorCategory.InvalidData, null);
         }
         EnhancedTimeSpan t = EnhancedTimeSpan.FromDays(365.0);
         if (this.Duration.Value > t)
         {
             base.WriteError(new ArgumentException(Strings.DurationShouldBeLessThan1Year(t.ToString()), "Duration"), ErrorCategory.InvalidData, null);
         }
     }
     base.InternalValidate();
 }
 protected override void InternalBeginProcessing()
 {
     TaskLogger.LogEnter();
     base.InternalBeginProcessing();
     this.helper.ParseAndValidateIdentity(this.Identity, true);
     if (base.Fields.IsModified("ApplyVersion"))
     {
         MonitoringOverrideHelpers.ValidateApplyVersion(this.ApplyVersion);
     }
     if (base.Fields.IsModified("Duration"))
     {
         MonitoringOverrideHelpers.ValidateOverrideDuration(this.Duration);
     }
     else
     {
         this.Duration = new EnhancedTimeSpan?(EnhancedTimeSpan.FromDays(365.0));
     }
     TaskLogger.LogExit();
 }
Пример #5
0
 internal override void StampPersistableDefaultValues()
 {
     if (!base.IsModified(UMMailboxPolicySchema.PINLifetime))
     {
         this.PINLifetime = EnhancedTimeSpan.FromDays(60.0);
     }
     if (!base.IsModified(UMMailboxPolicySchema.LogonFailuresBeforePINReset))
     {
         this.LogonFailuresBeforePINReset = 5;
     }
     if (!base.IsModified(UMMailboxPolicySchema.MaxLogonAttempts))
     {
         this.MaxLogonAttempts = 15;
     }
     if (!base.IsModified(UMMailboxPolicySchema.AllowMissedCallNotifications))
     {
         this.AllowMissedCallNotifications = true;
     }
     base.StampPersistableDefaultValues();
 }
Пример #6
0
        public virtual void ProcessPolicyParams(ActiveSyncMailboxPolicyObject originalPolicy)
        {
            bool   flag  = originalPolicy == null;
            bool   flag2 = this.DevicePasswordEnabled ?? (!flag && originalPolicy.DevicePasswordEnabled);
            object value;

            if (this.CheckAndParseParams <EnhancedTimeSpan>(true, this.IsDevicePolicyRefreshIntervalSet, flag ? null : new bool?(originalPolicy.IsDevicePolicyRefreshIntervalSet), this.DevicePolicyRefreshInterval, (string x) => EnhancedTimeSpan.FromHours(double.Parse(x)), out value))
            {
                base["DevicePolicyRefreshInterval"] = value;
            }
            if (this.CheckAndParseParams <int>(true, this.IsMaxEmailBodyTruncationSizeSet, flag ? null : new bool?(originalPolicy.IsMaxEmailBodyTruncationSizeSet), this.MaxEmailBodyTruncationSize, (string x) => int.Parse(x), out value))
            {
                base["MaxEmailBodyTruncationSize"] = value;
            }
            if (this.CheckAndParseParams <ByteQuantifiedSize>(true, this.IsMaxAttachmentSizeSet, flag ? null : new bool?(originalPolicy.IsMaxAttachmentSizeSet), this.MaxAttachmentSize, (string x) => ByteQuantifiedSize.FromKB(ulong.Parse(x)), out value))
            {
                base["MaxAttachmentSize"] = value;
            }
            if (flag2)
            {
                if (this.AlphanumericDevicePasswordRequired == true || (!flag && this.AlphanumericDevicePasswordRequired == null && originalPolicy.AlphanumericDevicePasswordRequired))
                {
                    int?minDevicePasswordComplexCharacters = this.MinDevicePasswordComplexCharacters;
                    int?num = (minDevicePasswordComplexCharacters != null) ? new int?(minDevicePasswordComplexCharacters.GetValueOrDefault()) : ((flag || originalPolicy.AlphanumericDevicePasswordRequired) ? this.MinDevicePasswordComplexCharacters : new int?(3));
                    if (num != null)
                    {
                        base["MinDevicePasswordComplexCharacters"] = num;
                    }
                }
                if (this.CheckAndParseParams <int>(false, this.IsMinDevicePasswordLengthSet, flag ? null : new bool?(originalPolicy.IsMinDevicePasswordLengthSet), this.MinDevicePasswordLength ?? ((flag || originalPolicy.IsMinDevicePasswordLengthSet) ? this.MinDevicePasswordLength : "4"), (string x) => int.Parse(x), out value))
                {
                    base["MinDevicePasswordLength"] = value;
                }
                if (this.CheckAndParseParams <int>(false, this.IsMinDevicePasswordLengthSet, flag ? null : new bool?(originalPolicy.IsMinDevicePasswordLengthSet), this.MinDevicePasswordLength ?? ((flag || originalPolicy.IsMinDevicePasswordLengthSet) ? this.MinDevicePasswordLength : "4"), (string x) => int.Parse(x), out value))
                {
                    base["MinDevicePasswordLength"] = value;
                }
                if (this.CheckAndParseParams <int>(true, this.IsMaxDevicePasswordFailedAttemptsSet, flag ? null : new bool?(originalPolicy.IsMaxDevicePasswordFailedAttemptsSet), this.MaxDevicePasswordFailedAttempts ?? ((flag || originalPolicy.IsMaxDevicePasswordFailedAttemptsSet) ? this.MaxDevicePasswordFailedAttempts : "8"), (string x) => int.Parse(x), out value))
                {
                    base["MaxDevicePasswordFailedAttempts"] = value;
                }
                if (this.CheckAndParseParams <EnhancedTimeSpan>(true, this.IsDevicePasswordExpirationSet, flag ? null : new bool?(originalPolicy.IsDevicePasswordExpirationSet), this.DevicePasswordExpiration ?? ((flag || originalPolicy.IsDevicePasswordExpirationSet) ? this.DevicePasswordExpiration : "90"), (string x) => EnhancedTimeSpan.FromDays(double.Parse(x)), out value))
                {
                    base["DevicePasswordExpiration"] = value;
                }
                if (this.CheckAndParseParams <EnhancedTimeSpan>(true, this.IsMaxInactivityTimeDeviceLockSet, flag ? null : new bool?(originalPolicy.IsMaxInactivityTimeDeviceLockSet), this.MaxInactivityTimeDeviceLock ?? ((flag || originalPolicy.IsMaxInactivityTimeDeviceLockSet) ? this.MaxInactivityTimeDeviceLock : "15"), (string x) => EnhancedTimeSpan.FromMinutes(double.Parse(x)), out value))
                {
                    base["MaxInactivityTimeDeviceLock"] = value;
                }
                if (this.RequireDeviceEncryption != null)
                {
                    base["RequireDeviceEncryption"] = this.RequireDeviceEncryption;
                }
                if (this.RequireStorageCardEncryption != null)
                {
                    base["RequireStorageCardEncryption"] = this.RequireStorageCardEncryption;
                }
                if (this.AllowSimpleDevicePassword != null)
                {
                    base["AllowSimpleDevicePassword"] = this.AllowSimpleDevicePassword;
                }
                if (this.AlphanumericDevicePasswordRequired != null)
                {
                    base["AlphanumericDevicePasswordRequired"] = this.AlphanumericDevicePasswordRequired;
                }
                if (this.PasswordRecoveryEnabled != null)
                {
                    base["PasswordRecoveryEnabled"] = this.PasswordRecoveryEnabled;
                }
                if (this.DevicePasswordHistory != null)
                {
                    base["DevicePasswordHistory"] = this.DevicePasswordHistory;
                }
            }
        }
Пример #7
0
        public override void CopyFolderProperties(FolderRecWrapper sourceFolderRecWrapper, ISourceFolder sourceFolder, IDestinationFolder destFolder, FolderRecDataFlags dataToCopy, out bool wasPropertyCopyingSkipped)
        {
            Guid empty  = Guid.Empty;
            bool isRoot = base.IsRoot;
            bool flag   = false;

            wasPropertyCopyingSkipped = false;
            FolderMapping folderMapping = sourceFolderRecWrapper as FolderMapping;

            while (folderMapping.WKFType != WellKnownFolderType.Root)
            {
                if (folderMapping.IsLegacyPublicFolder)
                {
                    return;
                }
                folderMapping = (folderMapping.Parent as FolderMapping);
            }
            if (destFolder == null)
            {
                if (!isRoot || ((FolderMapping)sourceFolderRecWrapper).IsSystemPublicFolder)
                {
                    MrsTracer.Service.Debug("Skipping final property copying for \"{0}\" folder since it's contents don't reside in this mailbox", new object[]
                    {
                        sourceFolderRecWrapper.FullFolderName
                    });
                    return;
                }
                throw new FolderCopyFailedPermanentException(sourceFolderRecWrapper.FullFolderName);
            }
            else
            {
                PropValueData[] props = destFolder.GetProps(new PropTag[]
                {
                    PropTag.ReplicaList,
                    PropTag.IpmWasteBasketEntryId
                });
                IDataConverter <PropValue, PropValueData> dataConverter = new PropValueConverter();
                PropValue nativeRepresentation = dataConverter.GetNativeRepresentation(props[0]);
                byte[]    array = nativeRepresentation.Value as byte[];
                if (!nativeRepresentation.IsNull() && !nativeRepresentation.IsError() && array != null)
                {
                    StorePropertyDefinition replicaList = CoreFolderSchema.ReplicaList;
                    string[] stringArrayFromBytes       = ReplicaListProperty.GetStringArrayFromBytes(array);
                    if (stringArrayFromBytes.Length > 0 && GuidHelper.TryParseGuid(stringArrayFromBytes[0], out empty))
                    {
                        flag = (empty == base.TargetMailboxGuid);
                    }
                }
                FolderStateSnapshot folderStateSnapshot = base.ICSSyncState[sourceFolderRecWrapper.EntryId];
                FolderState         state = folderStateSnapshot.State;
                if (sourceFolder.GetFolderRec(this.GetAdditionalFolderPtags(), GetFolderRecFlags.None).IsGhosted)
                {
                    folderStateSnapshot.State |= FolderState.IsGhosted;
                }
                else
                {
                    folderStateSnapshot.State &= ~FolderState.IsGhosted;
                }
                if (state != folderStateSnapshot.State)
                {
                    base.SaveICSSyncState(false);
                }
                if (!isRoot && !flag)
                {
                    return;
                }
                List <PropValueData> list = new List <PropValueData>(2);
                bool flag2 = false;
                if (flag)
                {
                    PropValue nativeRepresentation2 = dataConverter.GetNativeRepresentation(sourceFolder.GetProps(new PropTag[]
                    {
                        PropTag.PfProxy
                    })[0]);
                    if (!nativeRepresentation2.IsNull() && !nativeRepresentation2.IsError())
                    {
                        byte[] array2 = nativeRepresentation2.Value as byte[];
                        if (array2 != null && array2.Length == 16 && new Guid(array2) != Guid.Empty)
                        {
                            Guid a     = Guid.Empty;
                            bool flag3 = base.Flags.HasFlag(MailboxCopierFlags.CrossOrg);
                            if (flag3)
                            {
                                a = destFolder.LinkMailPublicFolder(LinkMailPublicFolderFlags.EntryId, sourceFolderRecWrapper.EntryId);
                            }
                            else
                            {
                                a = destFolder.LinkMailPublicFolder(LinkMailPublicFolderFlags.ObjectGuid, array2);
                            }
                            if (a != Guid.Empty)
                            {
                                list.Add(new PropValueData(PropTag.PfProxy, a.ToByteArray()));
                                list.Add(new PropValueData(PropTag.PfProxyRequired, true));
                                flag2 = true;
                            }
                            else
                            {
                                base.Report.Append(new ReportEntry(MrsStrings.ReportFailedToLinkADPublicFolder(sourceFolderRecWrapper.FullFolderName, BitConverter.ToString(array2), BitConverter.ToString(sourceFolderRecWrapper.EntryId)), ReportEntryType.Warning));
                            }
                        }
                    }
                }
                if (!flag2)
                {
                    list.Add(new PropValueData(PropTag.PfProxy, Guid.Empty.ToByteArray()));
                    list.Add(new PropValueData(PropTag.PfProxyRequired, false));
                }
                List <PropValueData> list2 = new List <PropValueData>(9);
                if (isRoot)
                {
                    if (!flag)
                    {
                        dataToCopy &= (FolderRecDataFlags.SecurityDescriptors | FolderRecDataFlags.FolderAcls | FolderRecDataFlags.ExtendedAclInformation);
                    }
                    list2.AddRange(list);
                }
                else
                {
                    byte[] sessionSpecificEntryId = this.hierarchyMailbox.GetSessionSpecificEntryId(sourceFolderRecWrapper.EntryId);
                    using (IDestinationFolder folder = this.hierarchyMailbox.GetFolder(sessionSpecificEntryId))
                    {
                        if (folder == null)
                        {
                            MrsTracer.Service.Error("Something deleted destination hierarchy folder from under us", new object[0]);
                            throw new UnexpectedErrorPermanentException(-2147221238);
                        }
                        if (list.Count > 0)
                        {
                            folder.SetProps(list.ToArray());
                        }
                    }
                }
                base.CopyFolderProperties(sourceFolderRecWrapper, sourceFolder, destFolder, dataToCopy, out wasPropertyCopyingSkipped);
                PropTag[] pta = new PropTag[]
                {
                    PropTag.DisablePeruserRead,
                    PropTag.OverallAgeLimit,
                    PropTag.RetentionAgeLimit,
                    PropTag.PfQuotaStyle,
                    PropTag.PfOverHardQuotaLimit,
                    PropTag.PfStorageQuota,
                    PropTag.PfMsgSizeLimit
                };
                foreach (PropValueData propValueData in sourceFolder.GetProps(pta))
                {
                    PropValue nativeRepresentation3 = dataConverter.GetNativeRepresentation(propValueData);
                    if (!nativeRepresentation3.IsNull() && !nativeRepresentation3.IsError())
                    {
                        if (propValueData.PropTag == 1721303043 && (int)propValueData.Value > 0)
                        {
                            propValueData.Value = (int)EnhancedTimeSpan.FromDays((double)((int)propValueData.Value)).TotalSeconds;
                        }
                        list2.Add(propValueData);
                    }
                }
                if (list2.Count > 0)
                {
                    destFolder.SetProps(list2.ToArray());
                }
                return;
            }
        }
Пример #8
0
        private static Dictionary <Guid, StoreTagData> Deserialize(Stream xmlStream, IExchangePrincipal mailboxOwner, out List <Guid> deletedTags, out RetentionHoldData retentionHoldData, bool returnRetentionHoldData, out Dictionary <Guid, StoreTagData> defaultArchiveTagData, out bool fullCrawlRequired)
        {
            fullCrawlRequired = false;
            Dictionary <Guid, StoreTagData> dictionary = new Dictionary <Guid, StoreTagData>();

            defaultArchiveTagData = new Dictionary <Guid, StoreTagData>();
            retentionHoldData     = default(RetentionHoldData);
            deletedTags           = new List <Guid>();
            if (xmlStream.Length == 0L)
            {
                MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0} has empty config message.", mailboxOwner);
                return(dictionary);
            }
            using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream))
            {
                Exception ex = null;
                try
                {
                    xmlTextReader.MoveToContent();
                    if (returnRetentionHoldData)
                    {
                        if (!xmlTextReader.ReadToFollowing("RetentionHold"))
                        {
                            MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Config item exists, but there is no RetentionHold node in it.", mailboxOwner);
                        }
                        else
                        {
                            if (xmlTextReader.MoveToAttribute("Enabled"))
                            {
                                retentionHoldData.HoldEnabled = bool.Parse(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("RetentionComment"))
                            {
                                retentionHoldData.Comment = xmlTextReader.Value;
                            }
                            if (xmlTextReader.MoveToAttribute("RetentionUrl"))
                            {
                                retentionHoldData.Url = xmlTextReader.Value;
                            }
                            MrmFaiFormatter.Tracer.TraceDebug(0L, "Mailbox:{0}. Config item exists, and there is a RetentionHold node in it. HoldEnabled: {1}. Comment: {2}. Url: {3}", new object[]
                            {
                                mailboxOwner,
                                retentionHoldData.HoldEnabled,
                                retentionHoldData.Comment,
                                retentionHoldData.Url
                            });
                        }
                    }
                    while (!MrmFaiFormatter.IsTagNode(xmlTextReader) && !MrmFaiFormatter.IsArchiveSyncNode(xmlTextReader) && xmlTextReader.Read())
                    {
                    }
                    if (string.CompareOrdinal(xmlTextReader.Name, "ArchiveSync") == 0)
                    {
                        if (xmlTextReader.MoveToAttribute("FullCrawlRequired"))
                        {
                            fullCrawlRequired = bool.Parse(xmlTextReader.Value);
                        }
                        while (!MrmFaiFormatter.IsTagNode(xmlTextReader))
                        {
                            if (!xmlTextReader.Read())
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Config item exists, but there is no ArchiveSync node in it.", mailboxOwner);
                    }
                    for (;;)
                    {
                        bool flag  = string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0;
                        bool flag2 = string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0;
                        bool flag3 = string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0;
                        bool flag4 = string.CompareOrdinal(xmlTextReader.Name, "DeletedTag") == 0;
                        if (!flag && !flag2 && !flag3 && !flag4)
                        {
                            break;
                        }
                        MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Found at least 1 tag in Config item.", mailboxOwner);
                        if (flag4)
                        {
                            Guid empty = System.Guid.Empty;
                            if (xmlTextReader.MoveToAttribute("Guid"))
                            {
                                empty = new Guid(xmlTextReader.Value);
                            }
                            deletedTags.Add(empty);
                            xmlTextReader.Read();
                        }
                        else
                        {
                            StoreTagData storeTagData = new StoreTagData();
                            storeTagData.Tag = new RetentionTag();
                            storeTagData.Tag.IsArchiveTag = flag2;
                            if (xmlTextReader.MoveToAttribute("ObjectGuid"))
                            {
                                storeTagData.Tag.Guid = new Guid(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("Guid"))
                            {
                                storeTagData.Tag.RetentionId = new Guid(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("Name"))
                            {
                                storeTagData.Tag.Name = xmlTextReader.Value;
                            }
                            if (xmlTextReader.MoveToAttribute("Comment"))
                            {
                                storeTagData.Tag.Comment = xmlTextReader.Value;
                            }
                            if (xmlTextReader.MoveToAttribute("Type"))
                            {
                                storeTagData.Tag.Type = (ElcFolderType)Enum.Parse(typeof(ElcFolderType), xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("MustDisplayComment"))
                            {
                                storeTagData.Tag.MustDisplayCommentEnabled = bool.Parse(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("IsVisible"))
                            {
                                storeTagData.IsVisible = bool.Parse(xmlTextReader.Value);
                            }
                            if (xmlTextReader.MoveToAttribute("OptedInto"))
                            {
                                storeTagData.OptedInto = bool.Parse(xmlTextReader.Value);
                            }
                            xmlTextReader.Read();
                            if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedName") == 0)
                            {
                                storeTagData.Tag.LocalizedRetentionPolicyTagName = MrmFaiFormatter.ReadLocalizedStrings(xmlTextReader, "Name");
                            }
                            if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedComment") == 0)
                            {
                                storeTagData.Tag.LocalizedComment = MrmFaiFormatter.ReadLocalizedStrings(xmlTextReader, "Comment");
                            }
                            MrmFaiFormatter.Tracer.TraceDebug(0L, "Mailbox:{0}. Done reading the tag. Name: {1}. Type: {2}. IsVisible: {3}. OptedInto: {4}", new object[]
                            {
                                mailboxOwner,
                                storeTagData.Tag.Name,
                                storeTagData.Tag.Type,
                                storeTagData.IsVisible,
                                storeTagData.OptedInto
                            });
                            while (string.CompareOrdinal(xmlTextReader.Name, "ContentSettings") == 0)
                            {
                                ContentSetting contentSetting = new ContentSetting();
                                Guid           key;
                                if (xmlTextReader.MoveToAttribute("Guid"))
                                {
                                    key = new Guid(xmlTextReader.Value);
                                }
                                else
                                {
                                    key = default(Guid);
                                }
                                if (xmlTextReader.MoveToAttribute("ExpiryAgeLimit"))
                                {
                                    contentSetting.AgeLimitForRetention = new EnhancedTimeSpan?(EnhancedTimeSpan.FromDays(double.Parse(xmlTextReader.Value)));
                                }
                                contentSetting.RetentionEnabled = true;
                                if (xmlTextReader.MoveToAttribute("MessageClass"))
                                {
                                    contentSetting.MessageClass = xmlTextReader.Value;
                                }
                                if (xmlTextReader.MoveToAttribute("RetentionAction"))
                                {
                                    contentSetting.RetentionAction = (RetentionActionType)Enum.Parse(typeof(RetentionActionType), xmlTextReader.Value, true);
                                }
                                storeTagData.ContentSettings[key] = contentSetting;
                                MrmFaiFormatter.Tracer.TraceDebug(0L, "Mailbox:{0}. Done reading the content setting. RetentionEnabled: {1}. MessageClass: {2}. RetentionAction: {3}", new object[]
                                {
                                    mailboxOwner,
                                    contentSetting.RetentionEnabled,
                                    contentSetting.MessageClass,
                                    contentSetting.RetentionAction
                                });
                                xmlTextReader.Read();
                            }
                            if (!flag3)
                            {
                                dictionary[storeTagData.Tag.RetentionId] = storeTagData;
                            }
                            else
                            {
                                defaultArchiveTagData[storeTagData.Tag.RetentionId] = storeTagData;
                            }
                        }
                        if ((string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DeletedTag") == 0) && xmlTextReader.NodeType == XmlNodeType.EndElement)
                        {
                            xmlTextReader.Read();
                        }
                    }
                    MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Found no MTA or retention or DefaultArchive or Deleted tag in Config item.", mailboxOwner);
                }
                catch (XmlException ex2)
                {
                    ex = ex2;
                }
                catch (ArgumentException ex3)
                {
                    ex = ex3;
                }
                catch (FormatException ex4)
                {
                    ex = ex4;
                }
                if (ex != null)
                {
                    xmlStream.Position = 0L;
                    string text = new StreamReader(xmlStream).ReadToEnd();
                    MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal, string, Exception>(0L, "Mailbox:{0}. Config item is corrupt. Config item: '{1}'. Exception: '{2}'", mailboxOwner, text, ex);
                    Globals.ELCLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_CorruptTagConfigItem, null, new object[]
                    {
                        mailboxOwner,
                        text,
                        ex.ToString()
                    });
                }
            }
            return(dictionary);
        }
Пример #9
0
 public static object ExtractNullableEnhancedTimeSpanFromDays(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (typeof(EnhancedTimeSpan?) == propertyDefinition.Type)
     {
         object obj = null;
         if (MapiPropValueConvertor.TryCastValueToExtract(value, typeof(double), out obj))
         {
             double num = (double)obj;
             return((0.0 == num || -1.0 == num) ? null : new EnhancedTimeSpan?(EnhancedTimeSpan.FromDays((double)obj)));
         }
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
 }
Пример #10
0
 protected override object ParseObject(string s, IFormatProvider provider)
 {
     return(EnhancedTimeSpan.FromDays((double)long.Parse(s)));
 }
Пример #11
0
        internal static PolicyTagList GetPolicyTakListFromXmlStream(RetentionActionType type, Stream xmlStream, string sessionCultureName)
        {
            PolicyTagList policyTagList = new PolicyTagList();

            if (xmlStream.Length == 0L)
            {
                return(policyTagList);
            }
            using (XmlTextReader xmlTextReader = SafeXmlFactory.CreateSafeXmlTextReader(xmlStream))
            {
                try
                {
                    xmlTextReader.MoveToContent();
                    while ((xmlTextReader.NodeType != XmlNodeType.Element || (string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") != 0 && string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") != 0 && string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") != 0)) && xmlTextReader.Read())
                    {
                    }
                    for (;;)
                    {
                        bool flag  = string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0;
                        bool flag2 = string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0;
                        if (!flag && !flag2)
                        {
                            break;
                        }
                        PolicyTag policyTag = new PolicyTag();
                        policyTag.IsArchive = flag2;
                        if (xmlTextReader.MoveToAttribute("Guid"))
                        {
                            policyTag.PolicyGuid = new Guid(xmlTextReader.Value);
                        }
                        if (xmlTextReader.MoveToAttribute("Name"))
                        {
                            policyTag.Name = xmlTextReader.Value;
                        }
                        if (xmlTextReader.MoveToAttribute("Comment"))
                        {
                            policyTag.Description = xmlTextReader.Value;
                        }
                        if (xmlTextReader.MoveToAttribute("Type"))
                        {
                            string value;
                            switch (value = xmlTextReader.Value)
                            {
                            case "Calendar":
                                policyTag.Type = ElcFolderType.Calendar;
                                goto IL_341;

                            case "Contacts":
                                policyTag.Type = ElcFolderType.Contacts;
                                goto IL_341;

                            case "DeletedItems":
                                policyTag.Type = ElcFolderType.DeletedItems;
                                goto IL_341;

                            case "Drafts":
                                policyTag.Type = ElcFolderType.Drafts;
                                goto IL_341;

                            case "Inbox":
                                policyTag.Type = ElcFolderType.Inbox;
                                goto IL_341;

                            case "JunkEmail":
                                policyTag.Type = ElcFolderType.JunkEmail;
                                goto IL_341;

                            case "Journal":
                                policyTag.Type = ElcFolderType.Journal;
                                goto IL_341;

                            case "Notes":
                                policyTag.Type = ElcFolderType.Notes;
                                goto IL_341;

                            case "Outbox":
                                policyTag.Type = ElcFolderType.Outbox;
                                goto IL_341;

                            case "SentItems":
                                policyTag.Type = ElcFolderType.SentItems;
                                goto IL_341;

                            case "Tasks":
                                policyTag.Type = ElcFolderType.Tasks;
                                goto IL_341;

                            case "All":
                                policyTag.Type = ElcFolderType.All;
                                goto IL_341;

                            case "ManagedCustomFolder":
                                policyTag.Type = ElcFolderType.ManagedCustomFolder;
                                goto IL_341;

                            case "RssSubscriptions":
                                policyTag.Type = ElcFolderType.RssSubscriptions;
                                goto IL_341;

                            case "SyncIssues":
                                policyTag.Type = ElcFolderType.SyncIssues;
                                goto IL_341;

                            case "ConversationHistory":
                                policyTag.Type = ElcFolderType.ConversationHistory;
                                goto IL_341;
                            }
                            policyTag.Type = ElcFolderType.Personal;
                        }
IL_341:
                        if (xmlTextReader.MoveToAttribute("IsVisible"))
                        {
                            policyTag.IsVisible = bool.Parse(xmlTextReader.Value);
                        }
                        if (xmlTextReader.MoveToAttribute("OptedInto"))
                        {
                            policyTag.OptedInto = bool.Parse(xmlTextReader.Value);
                        }
                        while (string.CompareOrdinal(xmlTextReader.Name, "ContentSettings") != 0 && string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") != 0 && string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") != 0)
                        {
                            if (string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0)
                            {
                                break;
                            }
                            if (!xmlTextReader.Read())
                            {
                                break;
                            }
                            if (!string.IsNullOrEmpty(sessionCultureName))
                            {
                                if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedName") == 0)
                                {
                                    xmlTextReader.Read();
                                    bool flag3 = false;
                                    while (string.CompareOrdinal(xmlTextReader.Name, "LocalizedName") != 0)
                                    {
                                        if (!flag3 && !string.IsNullOrEmpty(xmlTextReader.Value))
                                        {
                                            string stringFromLocalizedStringPair = PolicyTagList.GetStringFromLocalizedStringPair(sessionCultureName, xmlTextReader.Value);
                                            if (stringFromLocalizedStringPair != null)
                                            {
                                                policyTag.Name = stringFromLocalizedStringPair;
                                                flag3          = true;
                                            }
                                        }
                                        if (!xmlTextReader.Read())
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (string.CompareOrdinal(xmlTextReader.Name, "LocalizedComment") == 0)
                                {
                                    xmlTextReader.Read();
                                    bool flag4 = false;
                                    while (string.CompareOrdinal(xmlTextReader.Name, "LocalizedComment") != 0)
                                    {
                                        if (!flag4 && !string.IsNullOrEmpty(xmlTextReader.Value))
                                        {
                                            string stringFromLocalizedStringPair2 = PolicyTagList.GetStringFromLocalizedStringPair(sessionCultureName, xmlTextReader.Value);
                                            if (stringFromLocalizedStringPair2 != null)
                                            {
                                                policyTag.Description = stringFromLocalizedStringPair2;
                                                flag4 = true;
                                            }
                                        }
                                        if (!xmlTextReader.Read())
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        while (string.CompareOrdinal(xmlTextReader.Name, "ContentSettings") == 0)
                        {
                            if (xmlTextReader.MoveToAttribute("ExpiryAgeLimit"))
                            {
                                policyTag.TimeSpanForRetention = EnhancedTimeSpan.FromDays(double.Parse(xmlTextReader.Value));
                            }
                            if (xmlTextReader.MoveToAttribute("RetentionAction"))
                            {
                                policyTag.RetentionAction = (RetentionActionType)Enum.Parse(typeof(RetentionActionType), xmlTextReader.Value, true);
                            }
                            xmlTextReader.Read();
                        }
                        if (type == (RetentionActionType)0 || (type == RetentionActionType.MoveToArchive && flag2) || (type != (RetentionActionType)0 && type != RetentionActionType.MoveToArchive && flag))
                        {
                            policyTagList[policyTag.PolicyGuid] = policyTag;
                        }
                        if ((string.CompareOrdinal(xmlTextReader.Name, "PolicyTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "ArchiveTag") == 0 || string.CompareOrdinal(xmlTextReader.Name, "DefaultArchiveTag") == 0) && xmlTextReader.NodeType == XmlNodeType.EndElement)
                        {
                            xmlTextReader.Read();
                        }
                    }
                }
                catch (XmlException ex)
                {
                }
                catch (ArgumentException ex2)
                {
                }
                catch (FormatException ex3)
                {
                }
            }
            return(policyTagList);
        }
Пример #12
0
        public static void SetObjectPreAction(DataRow inputRow, DataTable dataTable, DataObjectStore store)
        {
            List <string> list = new List <string>();

            if (DBNull.Value.Equals(inputRow["MinPasswordComplexCharacters"]))
            {
                inputRow["MinPasswordComplexCharacters"] = "3";
                list.Add("MinPasswordComplexCharacters");
            }
            if (DBNull.Value != inputRow["MaxPasswordFailedAttempts"] || DBNull.Value != inputRow["IsMaxPasswordFailedAttemptsSet"])
            {
                bool   isValueSet = DBNull.Value.Equals(inputRow["IsMaxPasswordFailedAttemptsSet"]) || (bool)inputRow["IsMaxPasswordFailedAttemptsSet"];
                string value      = (DBNull.Value != inputRow["MaxPasswordFailedAttempts"]) ? ((string)inputRow["MaxPasswordFailedAttempts"]) : "8";
                object value2;
                if (MobileDeviceMailboxPolicyService.CheckAndParseParams <int>(true, isValueSet, value, (string x) => int.Parse(x), out value2))
                {
                    inputRow["MaxPasswordFailedAttempts"] = value2;
                    list.Add("MaxPasswordFailedAttempts");
                    list.Add("IsMaxPasswordFailedAttemptsSet");
                }
            }
            if (DBNull.Value != inputRow["PasswordExpiration"] || DBNull.Value != inputRow["IsPasswordExpirationSet"])
            {
                bool   isValueSet = DBNull.Value.Equals(inputRow["IsPasswordExpirationSet"]) || (bool)inputRow["IsPasswordExpirationSet"];
                string value      = (DBNull.Value != inputRow["PasswordExpiration"]) ? ((string)inputRow["PasswordExpiration"]) : "90";
                object value2;
                if (MobileDeviceMailboxPolicyService.CheckAndParseParams <EnhancedTimeSpan>(true, isValueSet, value, (string x) => EnhancedTimeSpan.FromDays(double.Parse(x)), out value2))
                {
                    inputRow["PasswordExpiration"] = value2;
                    list.Add("PasswordExpiration");
                    list.Add("IsPasswordExpirationSet");
                }
            }
            if (DBNull.Value != inputRow["MaxInactivityTimeLock"] || DBNull.Value != inputRow["IsMaxInactivityTimeLockSet"])
            {
                bool   isValueSet = DBNull.Value.Equals(inputRow["IsMaxInactivityTimeLockSet"]) || (bool)inputRow["IsMaxInactivityTimeLockSet"];
                string value      = (DBNull.Value != inputRow["MaxInactivityTimeLock"]) ? ((string)inputRow["MaxInactivityTimeLock"]) : "15";
                object value2;
                if (MobileDeviceMailboxPolicyService.CheckAndParseParams <EnhancedTimeSpan>(true, isValueSet, value, (string x) => EnhancedTimeSpan.FromMinutes(double.Parse(x)), out value2))
                {
                    inputRow["MaxInactivityTimeLock"] = value2;
                    list.Add("MaxInactivityTimeLock");
                    list.Add("IsMaxInactivityTimeLockSet");
                }
            }
            if (DBNull.Value != inputRow["MinPasswordLength"] || DBNull.Value != inputRow["IsMinPasswordLengthSet"])
            {
                bool   isValueSet = DBNull.Value.Equals(inputRow["IsMinPasswordLengthSet"]) || (bool)inputRow["IsMinPasswordLengthSet"];
                string value      = (DBNull.Value != inputRow["MinPasswordLength"]) ? ((string)inputRow["MinPasswordLength"]) : 4.ToString();
                object value2;
                if (MobileDeviceMailboxPolicyService.CheckAndParseParams <int>(false, isValueSet, value, (string x) => int.Parse(x), out value2))
                {
                    inputRow["MinPasswordLength"] = value2;
                    list.Add("MinPasswordLength");
                    list.Add("IsMinPasswordLengthSet");
                }
            }
            if (list.Count > 0)
            {
                store.SetModifiedColumns(list);
            }
        }