예제 #1
0
 private int ReadLcid()
 {
     if (this.mapiStore != null)
     {
         PropValue prop = this.mapiStore.GetProp(PropTag.SortLocaleId);
         if (!prop.IsNull() && !prop.IsError())
         {
             return(prop.GetInt());
         }
         return(0);
     }
     else
     {
         this.storeSession.Mailbox.Load(new PropertyDefinition[]
         {
             SortLCIDContext.SortLciPropertyDefinition
         });
         object obj = this.storeSession.Mailbox[SortLCIDContext.SortLciPropertyDefinition];
         if (obj == null || obj is PropertyError)
         {
             return(0);
         }
         return((int)obj);
     }
 }
        private void WaitAndProcessProbeResponses(MapiFolder folder, string fromAddress, Dictionary <string, string> subjectTargets, ExDateTime probeSentTime)
        {
            List <byte[]> list  = new List <byte[]>();
            List <string> list2 = new List <string>();

            for (int i = 0; i < base.Task.ExecutionTimeout; i++)
            {
                foreach (KeyValuePair <string, string> keyValuePair in subjectTargets)
                {
                    if (!string.IsNullOrEmpty(keyValuePair.Value))
                    {
                        using (MapiMessage deliveryReceipt = TestMailFlowHelper.GetDeliveryReceipt(folder, keyValuePair.Key, false))
                        {
                            if (deliveryReceipt != null)
                            {
                                PropValue prop  = deliveryReceipt.GetProp(PropTag.MessageDeliveryTime);
                                PropValue prop2 = deliveryReceipt.GetProp(PropTag.EntryId);
                                PropValue prop3 = deliveryReceipt.GetProp(PropTag.Subject);
                                if (!prop.IsError() && prop.Value != null && prop3.Value != null)
                                {
                                    string text = prop3.Value.ToString();
                                    if (text.StartsWith("RSP: CrossPremiseMailFlowMonitoring-", StringComparison.OrdinalIgnoreCase))
                                    {
                                        EnhancedTimeSpan latency = ((ExDateTime)prop.GetDateTime() > probeSentTime) ? ((ExDateTime)prop.GetDateTime() - probeSentTime) : EnhancedTimeSpan.Zero;
                                        base.OutputResult(Strings.TestMailflowSucceeded(fromAddress, keyValuePair.Value), latency, base.IsRemoteTest);
                                    }
                                    else if (text.StartsWith("Undeliverable: CrossPremiseMailFlowMonitoring-", StringComparison.OrdinalIgnoreCase))
                                    {
                                        EnhancedTimeSpan latency2 = EnhancedTimeSpan.FromSeconds(0.0);
                                        string           info     = (string)deliveryReceipt.GetProp(PropTag.Body).Value;
                                        base.OutputResult(Strings.CrossPremiseProbeNdred(fromAddress, keyValuePair.Value, info), latency2, base.IsRemoteTest);
                                    }
                                    list2.Add(keyValuePair.Key);
                                    list.Add(prop2.GetBytes());
                                }
                            }
                        }
                    }
                }
                foreach (string key in list2)
                {
                    subjectTargets.Remove(key);
                }
                list2.Clear();
                if (subjectTargets.Count == 0)
                {
                    break;
                }
                Thread.Sleep(1000);
            }
            foreach (KeyValuePair <string, string> keyValuePair2 in subjectTargets)
            {
                if (!string.IsNullOrEmpty(keyValuePair2.Value))
                {
                    EnhancedTimeSpan latency3 = EnhancedTimeSpan.FromSeconds(0.0);
                    base.OutputResult(Strings.MapiTransactionResultFailure, latency3, base.IsRemoteTest);
                }
            }
            folder.DeleteMessages(DeleteMessagesFlags.ForceHardDelete, list.ToArray());
        }
예제 #3
0
 public static DateTime GetDateTimeOrDefault(PropValue pv)
 {
     if (pv.IsError() || pv.IsNull() || pv.Value == null)
     {
         return(DateTime.MinValue);
     }
     return(pv.GetDateTime());
 }
예제 #4
0
            // Token: 0x0600135B RID: 4955 RVA: 0x00070C94 File Offset: 0x0006EE94
            public override void AddPropertyValue(ADRawEntry adRawEntry, PropRow propRow, OABFileRecord oabFileRecord, int index)
            {
                PropValue propValue = propRow.Properties[index];

                if (propValue.IsError() || propValue.Value == null)
                {
                    return;
                }
                this.AddPropTagToTruncatedPropertiesProperty(oabFileRecord);
            }
예제 #5
0
        protected virtual ulong GetFolderRulesSize(Folder folder)
        {
            ulong     result = 0UL;
            PropValue prop   = folder.MapiFolder.GetProp(PropTag.RulesSize);

            if (!prop.IsError() && prop.Value != null)
            {
                result = (ulong)((long)prop.GetInt());
            }
            return(result);
        }
예제 #6
0
            // Token: 0x06001357 RID: 4951 RVA: 0x00070C30 File Offset: 0x0006EE30
            public override void AddPropertyValue(ADRawEntry adRawEntry, PropRow propRow, OABFileRecord oabFileRecord, int index)
            {
                PropValue propValue = propRow.Properties[index];

                if (propValue.IsError())
                {
                    return;
                }
                oabFileRecord.PropertyValues[index] = new OABPropertyValue
                {
                    PropTag = (PropTag)2355953922U,
                    Value   = propValue.Value
                };
            }
예제 #7
0
            // Token: 0x0600135E RID: 4958 RVA: 0x00070DE0 File Offset: 0x0006EFE0
            public override void AddPropertyValue(ADRawEntry adRawEntry, PropRow propRow, OABFileRecord oabFileRecord, int index)
            {
                PropValue propValue = propRow.Properties[index];

                if (propValue.IsError())
                {
                    return;
                }
                try
                {
                    if (propValue.PropType == PropType.StringArray)
                    {
                        string[] stringArray = propValue.GetStringArray();
                        if (stringArray != null)
                        {
                            string[] value = (from s in stringArray
                                              select this.ValidString(s, adRawEntry.Id.ToString(), propValue.PropTag.ToString()) into v
                                              orderby v
                                              select v).ToArray <string>();
                            oabFileRecord.PropertyValues[index] = new OABPropertyValue
                            {
                                PropTag = this.propTag,
                                Value   = value
                            };
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    OABLogger.LogRecord(TraceType.DebugTrace, "MultivaluedProperty.AddPropertyValue: Informational only: Unable to validate strings in object {0}, property {1}. Reason: {2}", new object[]
                    {
                        adRawEntry.Id.ToString(),
                        propValue.PropTag.ToString(),
                        ex.Message
                    });
                }
                object obj = this.SortValues(propValue);

                if (obj != null)
                {
                    oabFileRecord.PropertyValues[index] = new OABPropertyValue
                    {
                        PropTag = this.propTag,
                        Value   = obj
                    };
                }
            }
        public static byte[] GetDumpsterEntryIdFromFolderRec(FolderRec folderRec)
        {
            ArgumentValidator.ThrowIfNull("folderRec", folderRec);
            if (folderRec.AdditionalProps != null)
            {
                foreach (PropValueData data in folderRec.AdditionalProps)
                {
                    PropValue native = DataConverter <PropValueConverter, PropValue, PropValueData> .GetNative(data);

                    if (!native.IsNull() && !native.IsError() && native.PropTag == PropTag.IpmWasteBasketEntryId)
                    {
                        return(native.GetBytes());
                    }
                }
            }
            return(null);
        }
예제 #9
0
            // Token: 0x0600136A RID: 4970 RVA: 0x00071524 File Offset: 0x0006F724
            public override void AddPropertyValue(ADRawEntry adRawEntry, PropRow propRow, OABFileRecord oabFileRecord, int index)
            {
                if (!(bool)adRawEntry[this.isOrganizationalProperty])
                {
                    if ((bool)adRawEntry[this.placeholderProperty])
                    {
                        base.AddPropTagToTruncatedPropertiesProperty(oabFileRecord);
                    }
                    return;
                }
                PropValue propValue = propRow.Properties[index];

                if (propValue.IsError())
                {
                    return;
                }
                oabFileRecord.PropertyValues[index] = new OABPropertyValue
                {
                    PropTag = this.propTag,
                    Value   = propValue.Value
                };
            }
예제 #10
0
            // Token: 0x06001362 RID: 4962 RVA: 0x000711B8 File Offset: 0x0006F3B8
            public override void AddPropertyValue(ADRawEntry adRawEntry, PropRow propRow, OABFileRecord oabFileRecord, int index)
            {
                PropValue propValue = propRow.Properties[index];

                if (propValue.IsError())
                {
                    return;
                }
                object obj = base.SortValues(propValue);

                if (obj == null || !(obj is byte[][]))
                {
                    return;
                }
                byte[][] array = this.FilterX509Certificates((byte[][])obj);
                if (array != null)
                {
                    oabFileRecord.PropertyValues[index] = new OABPropertyValue
                    {
                        PropTag = this.propTag,
                        Value   = array
                    };
                }
            }
예제 #11
0
        // Token: 0x06001351 RID: 4945 RVA: 0x00070AF0 File Offset: 0x0006ECF0
        public virtual void AddPropertyValue(ADRawEntry adRawEntry, PropRow propRow, OABFileRecord oabFileRecord, int index)
        {
            PropValue propValue = propRow.Properties[index];

            if (propValue.IsError())
            {
                return;
            }
            if (propValue.PropType == PropType.String)
            {
                string value = this.ValidString((string)propValue.Value, adRawEntry.Id.ToString(), propValue.PropTag.ToString());
                oabFileRecord.PropertyValues[index] = new OABPropertyValue
                {
                    PropTag = this.propTag,
                    Value   = value
                };
                return;
            }
            oabFileRecord.PropertyValues[index] = new OABPropertyValue
            {
                PropTag = this.propTag,
                Value   = propValue.Value
            };
        }
예제 #12
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;
            }
        }
예제 #13
0
        private object ConvertValue(ADPropertyDefinition propertyDefinition, PropValue propValue)
        {
            if (propValue.IsError() || propValue.IsNull())
            {
                return(null);
            }
            PropType propType = propValue.PropType;

            object[] values;
            if (propType <= PropType.SysTime)
            {
                if (propType <= PropType.Boolean)
                {
                    if (propType != PropType.Int && propType != PropType.Boolean)
                    {
                        goto IL_174;
                    }
                }
                else
                {
                    switch (propType)
                    {
                    case PropType.AnsiString:
                        values = new object[]
                        {
                            this.encoding.GetString(propValue.GetBytes())
                        };
                        goto IL_18F;

                    case PropType.String:
                        break;

                    default:
                        if (propType != PropType.SysTime)
                        {
                            goto IL_174;
                        }
                        break;
                    }
                }
            }
            else if (propType <= PropType.Binary)
            {
                if (propType != PropType.Guid)
                {
                    if (propType != PropType.Binary)
                    {
                        goto IL_174;
                    }
                    values = new object[]
                    {
                        propValue.RawValue
                    };
                    goto IL_18F;
                }
            }
            else
            {
                switch (propType)
                {
                case PropType.AnsiStringArray:
                    values = Array.ConvertAll <byte[], object>(propValue.GetBytesArray(), (byte[] bytesValue) => this.encoding.GetString(bytesValue));
                    goto IL_18F;

                case PropType.StringArray:
                    values = Array.ConvertAll <string, object>(propValue.GetStringArray(), (string stringValue) => stringValue);
                    goto IL_18F;

                default:
                    if (propType != PropType.BinaryArray)
                    {
                        goto IL_174;
                    }
                    values = Array.ConvertAll <byte[], object>(propValue.GetBytesArray(), (byte[] bytesValue) => bytesValue);
                    goto IL_18F;
                }
            }
            values = new object[]
            {
                propValue.RawValue.ToString()
            };
            goto IL_18F;
IL_174:
            throw new InvalidOperationException(string.Format("Property type {0} is not supported", propValue.GetType()));
            object result;

            try
            {
IL_18F:
                result = ADValueConvertor.GetValueFromDirectoryAttributeValues(propertyDefinition, values);
            }
            catch (DataValidationException arg)
            {
                NspiPropertyMap.Tracer.TraceWarning <string, DataValidationException>((long)this.GetHashCode(), "Unable to handle property {0} because it has invalid value, exception: {1}", propertyDefinition.Name, arg);
                result = null;
            }
            return(result);
        }