internal static object DecodeFolderFlags(object extendedFolderFlagsInternalPropertyValue)
 {
     if (extendedFolderFlagsInternalPropertyValue is byte[])
     {
         ExtendedFolderFlagsProperty.ParsedFlags parsedFlags = new ExtendedFolderFlagsProperty.ParsedFlags();
         using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader((byte[])extendedFolderFlagsInternalPropertyValue))
         {
             while (!reader.IsEnd)
             {
                 byte key = reader.ReadByte();
                 if (!reader.IsEnd)
                 {
                     byte b = reader.ReadByte();
                     if (reader.BytesRemaining >= (int)b)
                     {
                         parsedFlags[(ExtendedFolderFlagsProperty.FlagTag)key] = reader.ReadExactBytes((int)b);
                         continue;
                     }
                 }
                 return(new PropertyError(InternalSchema.ExtendedFolderFlags, PropertyErrorCode.CorruptedData));
             }
         }
         return(parsedFlags);
     }
     return(extendedFolderFlagsInternalPropertyValue);
 }
Esempio n. 2
0
 internal StoreParticipantEntryId(ParticipantEntryId.WabEntryFlag flags, ParticipantEntryId.Reader reader)
 {
     EnumValidator.AssertValid <ParticipantEntryId.WabEntryFlag>(flags);
     this.isMapiPDL         = StoreParticipantEntryId.WabEntryFlagToMapiPDL(flags);
     this.emailAddressIndex = StoreParticipantEntryId.WabEntryFlagToEmailAddressIndex(flags);
     this.ltEntryId         = reader.ReadLTEntryId();
     this.useWabFormat      = true;
     reader.EnsureEnd();
 }
Esempio n. 3
0
 private StoreParticipantEntryId(StoreObjectId itemId, bool isMapiPDL, EmailAddressIndex emailIndex, bool useWabFormat)
 {
     EnumValidator.AssertValid <EmailAddressIndex>(emailIndex);
     using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(itemId.ProviderLevelItemId))
     {
         this.ltEntryId = reader.ReadLTEntryId();
         reader.EnsureEnd();
     }
     this.isMapiPDL         = isMapiPDL;
     this.emailAddressIndex = emailIndex;
     this.useWabFormat      = useWabFormat;
 }
Esempio n. 4
0
 internal static ParticipantEntryId FromEntryId(byte[] bytes)
 {
     return(ParticipantEntryId.TranslateExceptions <ParticipantEntryId>(delegate
     {
         ParticipantEntryId result;
         using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(bytes))
         {
             result = ParticipantEntryId.FromEntryId(null, reader);
         }
         return result;
     }));
 }
Esempio n. 5
0
 internal static IList <ParticipantEntryId> FromFlatEntryList(byte[] bytes)
 {
     return(ParticipantEntryId.TranslateExceptions <IList <ParticipantEntryId> >(delegate
     {
         IList <ParticipantEntryId> result;
         using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(bytes))
         {
             result = ParticipantEntryId.FromFlatEntryList(reader);
         }
         return result;
     }));
 }
        internal OneOffParticipantEntryId(ParticipantEntryId.Reader reader)
        {
            this.flags = (OneOffFlag)reader.ReadUInt32();
            Encoding encoding = ((this.flags & (OneOffFlag)2147483648U) == (OneOffFlag)2147483648U) ? Encoding.Unicode : CTSGlobals.AsciiEncoding;

            this.emailDisplayName = Util.NullIf <string>(reader.ReadZString(encoding), string.Empty);
            this.emailAddressType = Util.NullIf <string>(reader.ReadZString(encoding), string.Empty);
            this.emailAddress     = Util.NullIf <string>(reader.ReadZString(encoding), string.Empty);
            reader.EnsureEnd();
            if (this.emailAddress == "Unknown")
            {
                this.emailAddress = null;
            }
        }
Esempio n. 7
0
        public static ParticipantEntryId TryFromEntryId(byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException("bytes");
            }
            ParticipantEntryId result;

            using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(bytes))
            {
                result = ParticipantEntryId.TryFromEntryId(reader);
            }
            return(result);
        }
Esempio n. 8
0
 private static ParticipantEntryId TryFromEntryId(ParticipantEntryId.Reader reader)
 {
     try
     {
         return(ParticipantEntryId.TranslateExceptions <ParticipantEntryId>(() => ParticipantEntryId.FromEntryId(null, reader)));
     }
     catch (NotSupportedException)
     {
     }
     catch (CorruptDataException)
     {
     }
     reader.BaseStream.Position = 0L;
     return(new UnrecognizedParticipantEntryId(reader.ReadBytes(reader.BytesRemaining)));
 }
Esempio n. 9
0
 private static StoreObjectId.StoreEntryId ParseStoreEntryId(byte[] entryId)
 {
     StoreObjectId.StoreEntryId result;
     using (ParticipantEntryId.Reader reader = new ParticipantEntryId.Reader(entryId))
     {
         try
         {
             bool flag = false;
             reader.BaseStream.Seek(22L, SeekOrigin.Begin);
             if (reader.BytesRemaining > 0)
             {
                 string text = reader.ReadZString(CTSGlobals.AsciiEncoding);
                 if (text.Equals("emsmdb.dll", StringComparison.OrdinalIgnoreCase))
                 {
                     flag = true;
                 }
             }
             if (flag)
             {
                 reader.BaseStream.Seek(36L, SeekOrigin.Begin);
             }
             else
             {
                 reader.BaseStream.Seek(0L, SeekOrigin.Begin);
             }
             result.MapiFlags  = reader.ReadInt32();
             result.MapiUid    = reader.ReadGuid();
             result.StoreFlags = (OpenStoreFlag)reader.ReadInt32();
             result.ServerName = reader.ReadZString(CTSGlobals.AsciiEncoding);
             if ((result.StoreFlags & OpenStoreFlag.Public) != OpenStoreFlag.Public)
             {
                 result.LegacyDn = reader.ReadZString(CTSGlobals.AsciiEncoding);
             }
             else
             {
                 result.LegacyDn = string.Empty;
             }
         }
         catch (EndOfStreamException innerException)
         {
             throw new CorruptDataException(ServerStrings.ExInvalidIdFormat, innerException);
         }
     }
     return(result);
 }
Esempio n. 10
0
        internal ADParticipantEntryId(ParticipantEntryId.WabEntryFlag?flags, ParticipantEntryId.Reader reader)
        {
            uint num = reader.ReadUInt32();

            if (num != 1U)
            {
                throw new NotSupportedException(ServerStrings.ExUnsupportedABProvider("Exchange WAB", num.ToString()));
            }
            this.legacyRecipientDisplayType = new LegacyRecipientDisplayType?((LegacyRecipientDisplayType)reader.ReadUInt32());
            if (flags == null && this.legacyRecipientDisplayType == LegacyRecipientDisplayType.MailUser)
            {
                this.legacyRecipientDisplayType = null;
            }
            this.legacyDN     = reader.ReadZString(CTSGlobals.AsciiEncoding);
            this.flags        = ADParticipantEntryId.ReplaceObjectTypeInformation(flags ?? ParticipantEntryId.WabEntryFlag.Envelope, ref this.legacyRecipientDisplayType, this.legacyDN);
            this.useWabFormat = (flags != null);
            reader.EnsureEnd();
        }
Esempio n. 11
0
        private static IList <ParticipantEntryId> FromFlatEntryList(ParticipantEntryId.Reader reader)
        {
            int num = reader.ReadInt32();

            reader.ReadInt32();
            IList <ParticipantEntryId> list = new List <ParticipantEntryId>();

            for (int i = 0; i < num; i++)
            {
                int num2 = reader.ReadInt32();
                list.Add(ParticipantEntryId.TryFromEntryId(reader.TearNext(num2)));
                if (reader.BytesRemaining != 0)
                {
                    reader.ReadPadding(num2, 4);
                }
            }
            reader.EnsureEnd();
            return(list);
        }
Esempio n. 12
0
        internal StoreParticipantEntryId(ParticipantEntryId.Reader reader)
        {
            uint num = reader.ReadUInt32();

            if (num != 3U)
            {
                throw new NotSupportedException(ServerStrings.ExUnsupportedABProvider("OLABP", num.ToString()));
            }
            uint num2 = reader.ReadUInt32();

            this.isMapiPDL         = (num2 == 5U);
            this.emailAddressIndex = StoreParticipantEntryId.IndexToEmailAddressIndex(reader.ReadUInt32());
            if (reader.ReadUInt32() != 70U)
            {
                throw new NotSupportedException(ServerStrings.ExInvalidParticipantEntryId);
            }
            this.ltEntryId = reader.ReadLTEntryId();
            if (reader.BytesRemaining != 3)
            {
                reader.EnsureEnd();
            }
        }
Esempio n. 13
0
 public Reader(ParticipantEntryId.Reader parentReader, int index, int count) : this(((MemoryStream)parentReader.BaseStream).GetBuffer(), index + parentReader.Origin, count)
 {
     this.Origin = index + parentReader.Origin;
 }
Esempio n. 14
0
 public ParticipantEntryId.Reader TearNext(int count)
 {
     ParticipantEntryId.Reader result = new ParticipantEntryId.Reader(this, (int)this.BaseStream.Position, count);
     this.BaseStream.Position += (long)count;
     return(result);
 }
Esempio n. 15
0
        private static ParticipantEntryId FromEntryId(ParticipantEntryId.WabEntryFlag?wrapperFlags, ParticipantEntryId.Reader reader)
        {
            Guid a = reader.ReadEntryHeader();

            if (a == ParticipantEntryId.OneOffProviderGuid)
            {
                using (ParticipantEntryId.Reader reader2 = reader.TearRest())
                {
                    return(new OneOffParticipantEntryId(reader2));
                }
            }
            if (a == ParticipantEntryId.WabProviderGuid)
            {
                ParticipantEntryId.WabEntryFlag wabEntryFlag = (ParticipantEntryId.WabEntryFlag)reader.ReadByte();
                switch ((byte)(wabEntryFlag & ParticipantEntryId.WabEntryFlag.ObjectTypeMask))
                {
                case 0:
                case 5:
                case 6:
                    break;

                case 1:
                case 2:
                    goto IL_D0;

                case 3:
                case 4:
                    using (ParticipantEntryId.Reader reader3 = reader.TearRest())
                    {
                        return(new StoreParticipantEntryId(wabEntryFlag, reader3));
                    }
                    break;

                default:
                    goto IL_D0;
                }
                if (wrapperFlags != null)
                {
                    throw new CorruptDataException(ServerStrings.ExInvalidParticipantEntryId);
                }
                using (ParticipantEntryId.Reader reader4 = reader.TearRest())
                {
                    return(ParticipantEntryId.FromEntryId(new ParticipantEntryId.WabEntryFlag?(wabEntryFlag), reader4));
                }
IL_D0:
                throw new NotSupportedException(ServerStrings.ExInvalidWABObjectType(wabEntryFlag & ParticipantEntryId.WabEntryFlag.ObjectTypeMask));
            }
            if (a == ParticipantEntryId.ExchangeProviderGuid)
            {
                using (ParticipantEntryId.Reader reader5 = reader.TearRest())
                {
                    return(new ADParticipantEntryId(wrapperFlags, reader5));
                }
            }
            if (a == ParticipantEntryId.OlabProviderGuid)
            {
                using (ParticipantEntryId.Reader reader6 = reader.TearRest())
                {
                    return(new StoreParticipantEntryId(reader6));
                }
            }
            throw new NotSupportedException(ServerStrings.ExUnsupportedABProvider(a.ToString(), string.Empty));
        }