internal static void SetTableFilter(StoreSession session, MapiProp propertyReference, MapiTable mapiTable, QueryFilter queryFilter)
 {
     if (queryFilter != null)
     {
         Restriction restriction = FilterRestrictionConverter.CreateRestriction(session, session.ExTimeZone, propertyReference, queryFilter);
         object      thisObject  = null;
         bool        flag        = false;
         try
         {
             if (session != null)
             {
                 session.BeginMapiCall();
                 session.BeginServerHealthCall();
                 flag = true;
             }
             if (StorageGlobals.MapiTestHookBeforeCall != null)
             {
                 StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
             }
             mapiTable.Restrict(restriction);
         }
         catch (MapiPermanentException ex)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]),
                 ex
             });
         }
         catch (MapiRetryableException ex2)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]),
                 ex2
             });
         }
         finally
         {
             try
             {
                 if (session != null)
                 {
                     session.EndMapiCall();
                     if (flag)
                     {
                         session.EndServerHealthCall();
                     }
                 }
             }
             finally
             {
                 if (StorageGlobals.MapiTestHookAfterCall != null)
                 {
                     StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                 }
             }
         }
     }
 }
Exemple #2
0
        internal MapiNotificationHandle Advise(byte[] entryId, AdviseFlags eventMask, MapiNotificationHandler handler, NotificationCallbackMode callbackMode)
        {
            StoreSession           session    = this.CoreObject.Session;
            object                 thisObject = null;
            bool                   flag       = false;
            MapiNotificationHandle result;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = this.MapiStore.Advise(entryId, eventMask, handler, callbackMode, (MapiNotificationClientFlags)0);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotAddNotification, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Mailbox::Advise.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotAddNotification, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Mailbox::Advise.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemple #3
0
        internal static string GetHeaderParameter(ComplexHeader header, string parameterName, int lengthLimit)
        {
            if (header == null)
            {
                return(null);
            }
            MimeParameter mimeParameter = header[parameterName];

            if (mimeParameter == null)
            {
                return(null);
            }
            string text = null;

            try
            {
                text = mimeParameter.Value;
            }
            catch (InvalidCharsetException)
            {
                StorageGlobals.ContextTraceDebug <string, string>(ExTraceGlobals.CcInboundMimeTracer, "InboundMimeConverter::GetHeaderParameter: Header[{0},{1}].Value throws InvalidCharsetException", header.Name, parameterName);
                return(null);
            }
            if (text != null && text.Length > lengthLimit)
            {
                StorageGlobals.ContextTraceDebug <string, string, int>(ExTraceGlobals.CcInboundMimeTracer, "InboundMimeConverter::GetHeaderParameter: Header[{0},{1}].Value exceeds length limit ({2})", header.Name, parameterName, lengthLimit);
                return(null);
            }
            return(text);
        }
Exemple #4
0
        public static T GetWithDirectoryExceptionTranslation <T>(Func <T> getter)
        {
            T result;

            try
            {
                result = getter();
            }
            catch (DataValidationException innerException)
            {
                throw new ObjectNotFoundException(ServerStrings.ADUserNotFound, innerException);
            }
            catch (DataSourceOperationException ex)
            {
                throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, null, "{0}. Failed due to directory exception {1}.", new object[]
                {
                    ex
                });
            }
            catch (DataSourceTransientException ex2)
            {
                throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "{0}. Failed due to directory exception {1}.", new object[]
                {
                    ex2
                });
            }
            return(result);
        }
Exemple #5
0
        public override MimePartInfo GetMimeStructure()
        {
            StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetMimeStructure.");
            this.CheckDisposed(null);
            MimePartInfo result;

            using (StorageGlobals.SetTraceContext(this.options))
            {
                using (StorageGlobals.SetTraceContext(this.itemIn))
                {
                    StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetMimeStructure)");
                    MimePartInfo mimeSkeleton = this.GetMimeSkeleton();
                    if (mimeSkeleton.IsBodySizeComputed)
                    {
                        this.GetHeaders();
                    }
                    else
                    {
                        using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter((MimeStreamWriter.Flags) 6, this.itemEncodingOptions))
                        {
                            this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.WriteMessageHeaders);
                        }
                    }
                    StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetMimeStructure)");
                    result = mimeSkeleton;
                }
            }
            return(result);
        }
Exemple #6
0
        public override MimePartHeaders GetHeaders()
        {
            StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetHeaders.1");
            this.CheckDisposed(null);
            MimePartHeaders headers;

            using (StorageGlobals.SetTraceContext(this.options))
            {
                using (StorageGlobals.SetTraceContext(this.itemIn))
                {
                    StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetHeaders.1)");
                    MimePartInfo mimeSkeleton = this.GetMimeSkeleton();
                    if (mimeSkeleton.Headers == null || mimeSkeleton.Headers.Count == 0)
                    {
                        using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter((MimeStreamWriter.Flags) 6, this.itemEncodingOptions))
                        {
                            this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.WriteMessageHeaders | ItemToMimeConverter.MimeFlags.SkipContent);
                        }
                    }
                    StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.1)");
                    headers = mimeSkeleton.Headers;
                }
            }
            return(headers);
        }
Exemple #7
0
 private bool GetText(Stream outStream, bool isSinglePartOnly)
 {
     StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetText.1");
     this.CheckDisposed(null);
     if (outStream == null)
     {
         throw new ArgumentNullException("outStream");
     }
     using (StorageGlobals.SetTraceContext(this.options))
     {
         using (StorageGlobals.SetTraceContext(this.itemIn))
         {
             StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetText.1)");
             MimePartInfo mimeSkeleton = this.GetMimeSkeleton();
             if (isSinglePartOnly && mimeSkeleton.IsMultipart)
             {
                 return(false);
             }
             using (Stream stream = new StreamWrapper(outStream, false))
             {
                 using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream, this.itemEncodingOptions, (MimeStreamWriter.Flags) 3))
                 {
                     this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.SkipMessageHeaders);
                 }
             }
             StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetText.1)");
         }
     }
     return(true);
 }
 private UserConfiguration(UserConfigurationName configurationName, UserConfigurationTypes type, IStorePropertyBag queryPropertyBag)
 {
     EnumValidator.AssertValid <UserConfigurationTypes>(type);
     this.queryPropertyBag = queryPropertyBag;
     StorageGlobals.TraceConstructIDisposable(this);
     this.disposeTracker = this.GetDisposeTracker();
 }
Exemple #9
0
 private void Dispose(bool disposing)
 {
     StorageGlobals.TraceDispose(this, this.isDisposed, disposing);
     if (!this.isDisposed)
     {
         if (disposing && this.disposeLock != null)
         {
             try
             {
                 this.disposeLock.EnterWriteLock();
                 this.isDisposed = true;
             }
             finally
             {
                 try
                 {
                     this.disposeLock.ExitWriteLock();
                 }
                 catch (SynchronizationLockException)
                 {
                 }
             }
         }
         this.InternalDispose(disposing);
         ExTraceGlobals.EventTracer.TraceDebug <EventPump>((long)this.GetHashCode(), "EventPump::Dispose. {0}", this);
     }
 }
        protected override Stream OpenValueReadStream(out int skipTrailingNulls)
        {
            TnefPropertyType tnefType         = this.PropertyReader.PropertyTag.TnefType;
            TnefPropertyType tnefPropertyType = tnefType;

            switch (tnefPropertyType)
            {
            case TnefPropertyType.String8:
            {
                skipTrailingNulls = 1;
                TextToText textToText = new TextToText(TextToTextConversionMode.ConvertCodePageOnly);
                textToText.InputEncoding  = this.GetString8Encoding();
                textToText.OutputEncoding = ConvertUtils.UnicodeEncoding;
                return(new ConverterStream(this.PropertyReader.GetRawValueReadStream(), textToText, ConverterStreamAccess.Read));
            }

            case TnefPropertyType.Unicode:
                skipTrailingNulls = 2;
                return(this.PropertyReader.GetRawValueReadStream());

            default:
                if (tnefPropertyType == TnefPropertyType.Binary)
                {
                    skipTrailingNulls = 0;
                    return(this.PropertyReader.GetRawValueReadStream());
                }
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "InboundTnefConverter::StreamLargeProperty: only supports binary and string properties.");
                throw new ConversionFailedException(ConversionFailureReason.CorruptContent);
            }
        }
Exemple #11
0
        private static string SaveStreamToTempFile(Stream stream)
        {
            StringBuilder stringBuilder        = new StringBuilder(256);
            string        conversionsDirectory = OleConverter.GetConversionsDirectory(true);

            if (NativeMethods.GetTempFileName(conversionsDirectory, "ole", 0U, stringBuilder) == 0)
            {
                StorageGlobals.ContextTraceError <string, int>(ExTraceGlobals.CcOleTracer, "OleConverter::SaveStreamToTempFile: failed to create temp file name, directory = {0}. Error {1}", conversionsDirectory, Marshal.GetLastWin32Error());
                throw new OleConversionFailedException(ServerStrings.OleConversionPrepareFailed);
            }
            try
            {
                using (FileStream fileStream = new FileStream(stringBuilder.ToString(), FileMode.OpenOrCreate, FileAccess.Write))
                {
                    Util.StreamHandler.CopyStreamData(stream, fileStream);
                    fileStream.Close();
                }
            }
            catch (IOException arg)
            {
                OleConverter.DeleteTempFile(stringBuilder.ToString());
                StorageGlobals.ContextTraceError <IOException>(ExTraceGlobals.CcOleTracer, "OleConverter::SaveStreamToTempFile: IOException caught. Exception:\n {0}", arg);
                throw new OleConversionFailedException(ServerStrings.OleConversionPrepareFailed);
            }
            return(stringBuilder.ToString());
        }
        internal static TResult ProtectedADCall <TResult>(Func <TResult> activeDirectoryCall)
        {
            TResult result;

            try
            {
                result = activeDirectoryCall();
            }
            catch (DataSourceOperationException ex)
            {
                throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, null, "StorageGlobals::{0} failed due to directory exception {1}.", new object[]
                {
                    activeDirectoryCall,
                    ex
                });
            }
            catch (DataSourceTransientException ex2)
            {
                throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "StorageGlobals::{0} failed due to directory exception {1}.", new object[]
                {
                    activeDirectoryCall,
                    ex2
                });
            }
            catch (DataValidationException ex3)
            {
                throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex3, null, "StorageGlobals::{0} failed due to directory exception {1}.", new object[]
                {
                    activeDirectoryCall,
                    ex3
                });
            }
            return(result);
        }
 private void DoAdCallAndTranslateExceptions(Action call, string methodName)
 {
     try
     {
         call();
     }
     catch (DataValidationException innerException)
     {
         throw new ObjectNotFoundException(ServerStrings.ADUserNotFound, innerException);
     }
     catch (DataSourceOperationException ex)
     {
         throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, null, "{0}. Failed due to directory exception {1}.", new object[]
         {
             methodName,
             ex
         });
     }
     catch (DataSourceTransientException ex2)
     {
         throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "{0}. Failed due to directory exception {1}.", new object[]
         {
             methodName,
             ex2
         });
     }
 }
Exemple #14
0
 public override void GetBody(Stream outStream)
 {
     StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetBody.1");
     this.CheckDisposed(null);
     if (outStream == null)
     {
         throw new ArgumentNullException("outStream");
     }
     using (StorageGlobals.SetTraceContext(this.options))
     {
         using (StorageGlobals.SetTraceContext(this.itemIn))
         {
             StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetBody.1)");
             MimePartInfo mimeSkeleton = this.GetMimeSkeleton();
             using (Stream stream = new StreamWrapper(outStream, false))
             {
                 using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream, this.itemEncodingOptions, (MimeStreamWriter.Flags) 6))
                 {
                     this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.WriteMessageHeaders);
                 }
             }
             StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetBody.1)");
         }
     }
 }
 protected MailboxSyncProvider()
 {
     this.itemQueryOptimizationFilter = MailboxSyncProvider.falseFilterInstance;
     base..ctor();
     StorageGlobals.TraceConstructIDisposable(this);
     this.disposeTracker = this.GetDisposeTracker();
 }
        internal ImportResult ImportMove(byte[] sourceParentSourceKey, byte[] sourceSourceKey, byte[] sourcePredecessorChangeList, byte[] destinationSourceKey, byte[] destinationChangeKey)
        {
            this.CheckDisposed(null);
            StoreSession        session = base.Session;
            bool                flag    = false;
            MapiCollectorStatus mapiCollectorStatus;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                mapiCollectorStatus = base.MapiCollector.ImportMessageMove(new PropValue(PropTag.ParentSourceKey, sourceParentSourceKey), new PropValue(PropTag.SourceKey, sourceSourceKey), new PropValue(PropTag.PredecessorChangeList, sourcePredecessorChangeList), new PropValue(PropTag.SourceKey, destinationSourceKey), new PropValue(PropTag.ChangeKey, destinationChangeKey));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportMessageMove, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the message move failed", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportMessageMove, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the message move failed", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(ContentsSynchronizationUploadContext.ConvertToImportResult(mapiCollectorStatus));
        }
Exemple #17
0
        private static void OnNewConverterCreatedCallback(IComWorker <IOleConverter> converterProcess, object requestParameters)
        {
            IOleConverter worker = converterProcess.Worker;
            uint          num    = 0U;
            string        conversionsDirectory = OleConverter.GetConversionsDirectory(true);

            if (conversionsDirectory == null)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: conversions directory full or inaccessible.");
                throw new OleConversionFailedException(ServerStrings.OleConversionFailed);
            }
            int num2;

            worker.ConfigureConverter(out num2, 4194304U, 262144U, conversionsDirectory, out num);
            if (num2 != 0)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: failed to configure converter.");
                throw new OleConversionFailedException(ServerStrings.OleConversionFailed, new COMException("HRESULT =", num2));
            }
            if (num != (uint)converterProcess.ProcessId)
            {
                StorageGlobals.ContextTraceError(ExTraceGlobals.CcOleTracer, "OleConverter::OnNewConverterCreatedCallback: process id mismatch.");
                throw new OleConversionFailedException(ServerStrings.OleConversionInitError(Process.GetCurrentProcess().ProcessName, converterProcess.ProcessId, (int)num));
            }
        }
Exemple #18
0
        private static Stream CreateResultStream(object result)
        {
            string text = result as string;

            if (text != null)
            {
                try
                {
                    return(new OleConverter.ConversionResultFileStream(text));
                }
                catch (IOException arg)
                {
                    OleConverter.DeleteTempFile(text);
                    StorageGlobals.ContextTraceError <IOException>(ExTraceGlobals.CcOleTracer, "OleConverter::CreateResultStream: IOException caught. Exception:\n {0}", arg);
                    throw new OleConversionFailedException(ServerStrings.OleConversionResultFailed);
                }
            }
            byte[] array = result as byte[];
            if (array != null)
            {
                return(new MemoryStream(array));
            }
            StorageGlobals.ContextTraceError <Type>(ExTraceGlobals.CcOleTracer, "OleConverter::CreateResultStream: result type is invalid, {0}.", result.GetType());
            throw new OleConversionFailedException(ServerStrings.OleConversionInvalidResultType);
        }
Exemple #19
0
        private byte[] GetDestinationSpecificEntryId(MapiStore hierarchyStore, StoreId folderId)
        {
            StoreSession storeSession = null;
            object       thisObject   = null;
            bool         flag         = false;

            byte[] result;
            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = hierarchyStore.CreateEntryId(hierarchyStore.GetFidFromEntryId(StoreId.GetStoreObjectId(folderId).ProviderLevelItemId));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RPCPrimaryHierarchyProvider.GetDestinationSpecificEntryId : folderId = {0}", folderId),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RPCPrimaryHierarchyProvider.GetDestinationSpecificEntryId : folderId = {0}", folderId),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemple #20
0
        private MapiStore GetHierarchyStore()
        {
            StoreSession storeSession = null;
            object       thisObject   = null;
            bool         flag         = false;
            MapiStore    result;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = MapiStore.OpenPublicStore(this.getLegacyDN(this.PrimaryHierarchyMailboxPrincipal).ToString(), this.userDn, null, null, null, string.Format("{0}:{1}", this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn, 81), ConnectFlag.UseDelegatedAuthPrivilege | ConnectFlag.UseNTLM | ConnectFlag.ConnectToExchangeRpcServerOnly, OpenStoreFlag.Public, CultureInfo.CurrentCulture, PublicFolderSession.FromClientSecurityContext(this.organizationId, this.clientSecurityContext), "Client=MSExchangeRPC");
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenMailbox(this.PrimaryHierarchyMailboxPrincipal.LegacyDn), ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PublicFolderRPCHierarchyProvider.GetHierarchyStore : ServerFullyQualifiedDomainName = {0}, UserLegacyDN = {1}.", this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn, this.userDn),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenMailbox(this.PrimaryHierarchyMailboxPrincipal.LegacyDn), ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PublicFolderRPCHierarchyProvider.GetHierarchyStore : ServerFullyQualifiedDomainName = {0}, UserLegacyDN = {1}.", this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn, this.userDn),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
        protected SynchronizationUploadContextBase(CoreFolder folder, StorageIcsState initialState)
        {
            Util.ThrowOnNullArgument(folder, "folder");
            this.folder = folder;
            StoreSession session = this.Session;
            bool         flag    = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.mapiCollector = this.MapiCreateCollector(initialState);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateCollector(base.GetType()), ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizationUploadContext::MapiCreateCollector failed", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateCollector(base.GetType()), ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizationUploadContext::MapiCreateCollector failed", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            this.mapiCollector.AllowWarnings = true;
        }
 protected override object ReadValue()
 {
     if (this.IsLargeValue())
     {
         StorageGlobals.ContextTraceError(ExTraceGlobals.CcInboundTnefTracer, "InboundTnefConverter::ReadValue: large property value");
         throw new ConversionFailedException(ConversionFailureReason.CorruptContent);
     }
     if (this.PropertyReader.IsMultiValuedProperty)
     {
         Type          elementType = InternalSchema.ClrTypeFromPropTagType(ConvertUtils.GetPropertyBaseType(this.PropertyReader.PropertyTag));
         List <object> list        = new List <object>();
         while (this.PropertyReader.ReadNextValue())
         {
             if (this.PropertyReader.IsLargeValue)
             {
                 throw new ConversionFailedException(ConversionFailureReason.CorruptContent, ServerStrings.LargeMultivaluedPropertiesNotSupportedInTNEF, null);
             }
             object obj = this.ReadSingleValue();
             if (obj == null)
             {
                 throw new ConversionFailedException(ConversionFailureReason.CorruptContent, ServerStrings.InvalidTnef, null);
             }
             list.Add(obj);
         }
         Array array = Array.CreateInstance(elementType, list.Count);
         for (int i = 0; i < array.Length; i++)
         {
             array.SetValue(list[i], i);
         }
         return(array);
     }
     return(this.ReadSingleValue());
 }
        public void TransportNewMail(StoreObjectId messageId, string messageClass, int messageFlags)
        {
            Util.ThrowOnNullArgument(messageId, "messageId");
            Util.ThrowOnNullArgument(messageClass, "messageClass");
            byte[]       providerLevelItemId = messageId.ProviderLevelItemId;
            StoreSession storeSession        = this.session;
            bool         flag = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.session.Mailbox.MapiStore.SpoolerNotifyMessageNewMail(providerLevelItemId, messageClass, messageFlags);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotNotifyMessageNewMail, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiStore.SpoolerNotifyMessageNewMail failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotNotifyMessageNewMail, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiStore.SpoolerNotifyMessageNewMail failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemple #24
0
            private void WriteTnefWriterPropertyValue(TnefPropertyTag propertyTag, object propertyValue)
            {
                TnefPropertyType tnefType = propertyTag.TnefType;

                if (tnefType == TnefPropertyType.AppTime || tnefType == (TnefPropertyType)4103)
                {
                    DateTime dateTime = (DateTime)Util.Date1601Utc.ToUtc();
                    try
                    {
                        dateTime = ConvertUtils.GetDateTimeFromOADate((double)propertyValue);
                    }
                    catch (ArgumentException arg)
                    {
                        StorageGlobals.ContextTraceError <double, ArgumentException>(ExTraceGlobals.CcOutboundTnefTracer, "TnefContentWriter::WriteTnefWriterPropertyValue: ArgumentException processing date {0}, {1}.", (double)propertyValue, arg);
                    }
                    propertyValue = dateTime;
                }
                propertyValue = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(propertyValue);
                if (propertyValue is DateTime)
                {
                    DateTime dateTime2 = (DateTime)propertyValue;
                    if ((ExDateTime)dateTime2 < Util.Date1601Utc)
                    {
                        propertyValue = (DateTime)Util.Date1601Utc;
                    }
                }
                this.tnefWriter.WritePropertyValue(propertyValue);
            }
Exemple #25
0
        public byte[] GetLongTermIdFromId(long id)
        {
            StoreSession storeSession = this.session;
            bool         flag         = false;

            byte[] result;
            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = this.session.Mailbox.MapiStore.GlobalIdFromId(id);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetLongTermIdFromId(id), ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("StoreSession::GetLongTermIdFromId failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetLongTermIdFromId(id), ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("StoreSession::GetLongTermIdFromId failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemple #26
0
        public bool Remove(long item)
        {
            StoreSession storeSession = this.session;
            bool         flag         = false;
            bool         result;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = this.gids.Remove(this.session.Mailbox.MapiStore.GlobalIdFromId(item));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.RuleHistoryError, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RuleHistory.Remove. item = {0}.", item),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.RuleHistoryError, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RuleHistory.Remove. item = {0}.", item),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
        private int GetMapiTableRowCount()
        {
            StoreSession storeSession = this.storeSession;
            bool         flag         = false;
            int          rowCount;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                rowCount = this.recipientTable.GetRowCount();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(rowCount);
        }
        private void SetRecipientColumnsAndSortOrderOnMapiTable(NativeStorePropertyDefinition[] recipientPropertyDefinitions)
        {
            ICollection <PropTag> columns      = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(this.mapiMessage, this.storeSession, recipientPropertyDefinitions);
            StoreSession          storeSession = this.storeSession;
            bool flag = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.recipientTable.SetColumns(columns);
                this.recipientTable.SortTable(new SortOrder(PropTag.RowId, SortFlags.Ascend), SortTableFlags.None);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
        internal ICollection <PropertyDefinition> GetAllFoundProperties()
        {
            PropTag[]    propTags     = null;
            StoreSession storeSession = this.StoreSession;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                propTags = this.mapiProp.GetPropList();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetPropertyList, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get propList from the mapiProp.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetPropertyList, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get propList from the mapiProp.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, this.storeSession.Mailbox.MapiStore, this.storeSession, propTags));
        }
Exemple #30
0
        internal void ImportChange(ExTimeZone exTimeZone, IList <PropertyDefinition> propertyDefinitions, IList <object> propertyValues)
        {
            this.CheckDisposed(null);
            PropValue[]  propValues = base.GetPropValuesFromValues(exTimeZone, propertyDefinitions, propertyValues).ToArray();
            StoreSession session    = base.Session;
            bool         flag       = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                base.MapiCollector.ImportFolderChange(propValues);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportFolderChange, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the folder change failed", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportFolderChange, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the folder change failed", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }