public StoreObjectId ResolveStoreObjectIdFromFolderPath(MapiFolderPath folderPath)
        {
            Util.ThrowOnNullArgument(folderPath, "folderPath");
            StoreObjectId storeObjectId;

            if (folderPath.IsNonIpmPath)
            {
                storeObjectId = this.PublicFolderSession.GetNonIpmSubtreeFolderId();
            }
            else
            {
                storeObjectId = this.PublicFolderSession.GetIpmSubtreeFolderId();
            }
            if (folderPath.Depth <= 0)
            {
                return(storeObjectId);
            }
            foreach (string text in folderPath)
            {
                QueryFilter seekFilter = new TextFilter(FolderSchema.DisplayName, text, MatchOptions.FullString, MatchFlags.IgnoreCase);
                using (Folder folder = Folder.Bind(this.PublicFolderSession, storeObjectId, PublicFolderDataProvider.FolderQueryReturnColumns))
                {
                    using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, PublicFolderDataProvider.FolderQuerySorts, PublicFolderDataProvider.FolderQueryReturnColumns))
                    {
                        if (!queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter, SeekToConditionFlags.AllowExtendedFilters))
                        {
                            return(null);
                        }
                        object[][] rows = queryResult.GetRows(1);
                        storeObjectId = ((VersionedId)rows[0][0]).ObjectId;
                    }
                }
            }
            return(storeObjectId);
        }
예제 #2
0
        public StoreObjectId ResolveStoreObjectIdFromFolderPath(MapiFolderPath folderPath)
        {
            Util.ThrowOnNullArgument(folderPath, "folderPath");
            StoreObjectId storeObjectId;

            if (folderPath.IsNonIpmPath)
            {
                storeObjectId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration);
            }
            else
            {
                storeObjectId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
            }
            if (folderPath.Depth <= 0)
            {
                return(storeObjectId);
            }
            foreach (string propertyValue in folderPath)
            {
                QueryFilter seekFilter = new ComparisonFilter(ComparisonOperator.Equal, FolderSchema.DisplayName, propertyValue);
                using (Folder folder = Folder.Bind(base.MailboxSession, storeObjectId, MailboxFolderDataProviderBase.FolderQueryReturnColumns))
                {
                    using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, MailboxFolderDataProviderBase.FolderQuerySorts, MailboxFolderDataProviderBase.FolderQueryReturnColumns))
                    {
                        if (!queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter))
                        {
                            return(null);
                        }
                        object[][] rows = queryResult.GetRows(1);
                        storeObjectId = ((VersionedId)rows[0][0]).ObjectId;
                    }
                }
            }
            return(storeObjectId);
        }
예제 #3
0
        protected override IConfigurable PrepareDataObject()
        {
            MailboxFolder mailboxFolder  = (MailboxFolder)base.PrepareDataObject();
            MailboxFolder mailboxFolder2 = (MailboxFolder)base.GetDataObject <MailboxFolder>(this.Parent, base.DataSession, null, new LocalizedString?(Strings.ErrorMailboxFolderNotFound(this.Parent.ToString())), new LocalizedString?(Strings.ErrorMailboxFolderNotUnique(this.Parent.ToString())));

            if (mailboxFolder2.FolderPath.IsNonIpmPath)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorCannotCreateFolderUnderNonIpmSubtree(this.Name, this.Parent.ToString())), ErrorCategory.InvalidOperation, this.Name);
            }
            if (mailboxFolder2.ExtendedFolderFlags != null && ((mailboxFolder2.ExtendedFolderFlags.Value & ExtendedFolderFlags.ExclusivelyBound) != (ExtendedFolderFlags)0 || (mailboxFolder2.ExtendedFolderFlags.Value & ExtendedFolderFlags.RemoteHierarchy) != (ExtendedFolderFlags)0))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorInvalidParentExtendedFolderFlags(this.Name, this.Parent.ToString(), string.Join(",", new string[]
                {
                    ExtendedFolderFlags.ExclusivelyBound.ToString(),
                    ExtendedFolderFlags.RemoteHierarchy.ToString()
                }))), ErrorCategory.InvalidOperation, this.Name);
            }
            mailboxFolder[MailboxFolderSchema.InternalParentFolderIdentity] = mailboxFolder2.InternalFolderIdentity.ObjectId;
            mailboxFolder.FolderPath     = MapiFolderPath.GenerateFolderPath(mailboxFolder2.FolderPath, mailboxFolder.Name);
            mailboxFolder.MailboxOwnerId = mailboxFolder2.MailboxOwnerId;
            mailboxFolder.SetDefaultFolderType(DefaultFolderType.None);
            if (string.IsNullOrEmpty(mailboxFolder.FolderClass))
            {
                if (DefaultFolderType.Root == mailboxFolder2.DefaultFolderType || string.IsNullOrEmpty(mailboxFolder2.FolderClass))
                {
                    mailboxFolder.FolderClass = "IPF.Note";
                }
                else
                {
                    mailboxFolder.FolderClass = mailboxFolder2.FolderClass;
                }
            }
            return(mailboxFolder);
        }
예제 #4
0
        internal static MapiFolderPath CalculateMailboxFolderPath(StoreSession session, StoreObjectId storeFolderId, StoreObjectId parentStoreFolderId, string displayName, Dictionary <StoreObjectId, MapiFolderPath> knownFolderPathsCache)
        {
            if (storeFolderId == null)
            {
                throw new ArgumentNullException("storeFolderId");
            }
            if (parentStoreFolderId == null)
            {
                throw new ArgumentNullException("parentStoreFolderId");
            }
            if (knownFolderPathsCache == null)
            {
                throw new ArgumentNullException("knownFolderPathsCache");
            }
            Stack <string>        stack          = new Stack <string>();
            Stack <StoreObjectId> stack2         = new Stack <StoreObjectId>();
            MapiFolderPath        mapiFolderPath = null;

            while (null == mapiFolderPath)
            {
                if (knownFolderPathsCache.ContainsKey(storeFolderId))
                {
                    mapiFolderPath = knownFolderPathsCache[storeFolderId];
                }
                else if (knownFolderPathsCache.ContainsKey(parentStoreFolderId))
                {
                    mapiFolderPath = knownFolderPathsCache[parentStoreFolderId];
                    stack.Push(displayName);
                    stack2.Push(storeFolderId);
                }
                else
                {
                    using (Folder folder = Folder.Bind(session, parentStoreFolderId, new PropertyDefinition[]
                    {
                        FolderSchema.DisplayName,
                        StoreObjectSchema.ParentItemId
                    }))
                    {
                        stack.Push(displayName);
                        stack2.Push(storeFolderId);
                        storeFolderId       = parentStoreFolderId;
                        parentStoreFolderId = (StoreObjectId)folder[StoreObjectSchema.ParentItemId];
                        displayName         = (string)folder[FolderSchema.DisplayName];
                    }
                }
            }
            MapiFolderPath mapiFolderPath2 = mapiFolderPath;

            while (0 < stack.Count)
            {
                mapiFolderPath2 = MapiFolderPath.GenerateFolderPath(mapiFolderPath2, stack.Pop());
                StoreObjectId key = stack2.Pop();
                if (!knownFolderPathsCache.ContainsKey(key))
                {
                    knownFolderPathsCache.Add(key, mapiFolderPath2);
                }
            }
            return(mapiFolderPath2);
        }
예제 #5
0
        protected override IConfigurable PrepareDataObject()
        {
            if (this.Path == null)
            {
                this.Path = new PublicFolderIdParameter(new PublicFolderId(MapiFolderPath.IpmSubtreeRoot));
            }
            PublicFolder publicFolder = null;

            try
            {
                publicFolder = (PublicFolder)base.GetDataObject <PublicFolder>(this.Path, base.DataSession, null, new LocalizedString?(Strings.ErrorPublicFolderNotFound(this.Path.ToString())), new LocalizedString?(Strings.ErrorPublicFolderNotUnique(this.Path.ToString())));
            }
            catch (NotSupportedException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidType, this.Name);
            }
            if (publicFolder.ExtendedFolderFlags != null && ((publicFolder.ExtendedFolderFlags.Value & ExtendedFolderFlags.ExclusivelyBound) != (ExtendedFolderFlags)0 || (publicFolder.ExtendedFolderFlags.Value & ExtendedFolderFlags.RemoteHierarchy) != (ExtendedFolderFlags)0))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorInvalidParentExtendedFolderFlags(this.Name, this.Path.ToString(), string.Join(",", new string[]
                {
                    ExtendedFolderFlags.ExclusivelyBound.ToString(),
                    ExtendedFolderFlags.RemoteHierarchy.ToString()
                }))), ErrorCategory.InvalidOperation, this.Name);
            }
            PublicFolder publicFolder2 = (PublicFolder)base.PrepareDataObject();

            publicFolder2.MailboxOwnerId = this.publicFolderDataProvider.PublicFolderSession.MailboxPrincipal.ObjectId;
            publicFolder2[MailboxFolderSchema.InternalParentFolderIdentity] = publicFolder.InternalFolderIdentity.ObjectId;
            publicFolder2.FolderPath = MapiFolderPath.GenerateFolderPath(publicFolder.FolderPath, this.Name);
            publicFolder2.Name       = this.Name;
            publicFolder2.PerUserReadStateEnabled = publicFolder.PerUserReadStateEnabled;
            publicFolder2.EformsLocaleId          = this.EformsLocaleId;
            if (this.Mailbox != null)
            {
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.FullyConsistent, base.SessionSettings, 237, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MapiTasks\\PublicFolder\\NewPublicFolder.cs");
                ADUser            aduser = (ADUser)base.GetDataObject <ADUser>(this.Mailbox, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.Mailbox.ToString())));
                if (aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
                {
                    base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorMailboxNotFound(this.Mailbox.ToString())), ExchangeErrorCategory.Client, this.Mailbox);
                }
                publicFolder2.ContentMailboxGuid = aduser.ExchangeGuid;
            }
            publicFolder2.SetDefaultFolderType(DefaultFolderType.None);
            if (string.IsNullOrEmpty(publicFolder2.FolderClass))
            {
                if (DefaultFolderType.Root == publicFolder.DefaultFolderType || string.IsNullOrEmpty(publicFolder.FolderClass))
                {
                    publicFolder2.FolderClass = "IPF.Note";
                }
                else
                {
                    publicFolder2.FolderClass = publicFolder.FolderClass;
                }
            }
            return(publicFolder2);
        }
예제 #6
0
        internal new static object IdentityGetter(IPropertyBag propertyBag)
        {
            VersionedId    versionedId    = (VersionedId)propertyBag[MailboxFolderSchema.InternalFolderIdentity];
            MapiFolderPath mapiFolderPath = (MapiFolderPath)propertyBag[MailboxFolderSchema.FolderPath];

            if (null != mapiFolderPath || versionedId != null)
            {
                return(new PublicFolderId((versionedId == null) ? null : versionedId.ObjectId, mapiFolderPath));
            }
            return(null);
        }
예제 #7
0
        internal static object IdentityGetter(IPropertyBag propertyBag)
        {
            ADObjectId     mailboxOwnerId = (ADObjectId)propertyBag[XsoMailboxConfigurationObjectSchema.MailboxOwnerId];
            VersionedId    versionedId    = (VersionedId)propertyBag[MailboxFolderSchema.InternalFolderIdentity];
            MapiFolderPath mapiFolderPath = (MapiFolderPath)propertyBag[MailboxFolderSchema.FolderPath];

            if (null != mapiFolderPath || versionedId != null)
            {
                return(new MailboxFolderId(mailboxOwnerId, (versionedId == null) ? null : versionedId.ObjectId, mapiFolderPath));
            }
            return(null);
        }
예제 #8
0
 public static MapiFolderPath Redact(MapiFolderPath folderPath, out string raw, out string redacted)
 {
     raw      = null;
     redacted = null;
     if (folderPath != null)
     {
         raw        = folderPath.ToString();
         redacted   = SuppressingPiiData.Redact(raw);
         folderPath = new MapiFolderPath('\\' + redacted);
     }
     return(folderPath);
 }
예제 #9
0
        internal new static object ParentFolderGetter(IPropertyBag propertyBag)
        {
            VersionedId    versionedId    = (VersionedId)propertyBag[MailboxFolderSchema.InternalFolderIdentity];
            StoreObjectId  storeObjectId  = (StoreObjectId)propertyBag[MailboxFolderSchema.InternalParentFolderIdentity];
            MapiFolderPath mapiFolderPath = (MapiFolderPath)propertyBag[MailboxFolderSchema.FolderPath];

            if (versionedId != null && versionedId.ObjectId != null && object.Equals(versionedId.ObjectId, storeObjectId))
            {
                return(null);
            }
            if ((null != mapiFolderPath && null != mapiFolderPath.Parent) || storeObjectId != null)
            {
                return(new PublicFolderId(storeObjectId, (null == mapiFolderPath) ? null : mapiFolderPath.Parent));
            }
            return(null);
        }
        public MailboxFolderIdParameter(string mailboxFolderId)
        {
            if (string.IsNullOrEmpty(mailboxFolderId))
            {
                throw new ArgumentNullException("mailboxFolderId");
            }
            this.rawIdentity = mailboxFolderId;
            int num = mailboxFolderId.IndexOf(':');

            if (-1 == num)
            {
                this.RawOwner      = new MailboxIdParameter(mailboxFolderId);
                this.RawFolderPath = MapiFolderPath.IpmSubtreeRoot;
                return;
            }
            string text  = mailboxFolderId.Substring(0, num);
            string text2 = mailboxFolderId.Substring(1 + num);

            if (!string.IsNullOrEmpty(text))
            {
                this.RawOwner = new MailboxIdParameter(text);
            }
            if (string.IsNullOrEmpty(text2))
            {
                throw new FormatException(Strings.ErrorInvalidMailboxFolderIdentity(this.rawIdentity));
            }
            try
            {
                if (text2[0] == '\\' || text2[0] == '￾')
                {
                    this.RawFolderPath = MapiFolderPath.Parse(text2);
                }
                else
                {
                    this.RawFolderStoreId = StoreObjectId.Deserialize(text2);
                }
            }
            catch (FormatException innerException)
            {
                throw new FormatException(Strings.ErrorInvalidMailboxFolderIdentity(this.rawIdentity), innerException);
            }
            catch (CorruptDataException innerException2)
            {
                throw new FormatException(Strings.ErrorInvalidMailboxFolderIdentity(this.rawIdentity), innerException2);
            }
        }
예제 #11
0
        internal static object ParentFolderGetter(IPropertyBag propertyBag)
        {
            ADObjectId     mailboxOwnerId = (ADObjectId)propertyBag[XsoMailboxConfigurationObjectSchema.MailboxOwnerId];
            VersionedId    versionedId    = (VersionedId)propertyBag[MailboxFolderSchema.InternalFolderIdentity];
            StoreObjectId  storeObjectId  = (StoreObjectId)propertyBag[MailboxFolderSchema.InternalParentFolderIdentity];
            MapiFolderPath mapiFolderPath = (MapiFolderPath)propertyBag[MailboxFolderSchema.FolderPath];

            if (versionedId != null && versionedId != null && object.Equals(versionedId.ObjectId, storeObjectId))
            {
                return(null);
            }
            if ((null != mapiFolderPath && null != mapiFolderPath.Parent) || storeObjectId != null)
            {
                return(new MailboxFolderId(mailboxOwnerId, storeObjectId, (null == mapiFolderPath) ? null : mapiFolderPath.Parent));
            }
            return(null);
        }
예제 #12
0
        internal static MapiFolder GetFolderByPath(MapiStore mapiStore, MapiFolderPath folderPath)
        {
            MapiFolder mapiFolder = null;
            MapiFolder folderByPath;

            try
            {
                folderByPath = Folder.GetFolderByPath(mapiStore, folderPath, out mapiFolder);
            }
            finally
            {
                if (mapiFolder != null)
                {
                    mapiFolder.Dispose();
                }
            }
            return(folderByPath);
        }
예제 #13
0
 public static PublicFolderId Parse(string input)
 {
     if (string.IsNullOrEmpty(input))
     {
         throw new FormatException(Strings.ExceptionFormatNotSupported);
     }
     try
     {
         return(new PublicFolderId(MapiFolderPath.Parse(input)));
     }
     catch (FormatException)
     {
     }
     try
     {
         return(new PublicFolderId(MapiEntryId.Parse(input)));
     }
     catch (FormatException)
     {
     }
     return(new PublicFolderId(input));
 }
예제 #14
0
 internal PublicFolderId(StoreObjectId storeObjectId, MapiFolderPath folderPath)
 {
     this.StoreObjectId  = storeObjectId;
     this.MapiFolderPath = folderPath;
 }
예제 #15
0
        internal static MapiFolder RetrieveMapiFolder(MapiStore store, FolderId identity, ref MapiFolder parent, Folder.IdentityConstructor idCtor, out FolderId realId)
        {
            realId = null;
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }
            Folder.CheckRequirementsOnIdentityToContinue(identity);
            MapiFolder mapiFolder = null;
            bool       flag       = false;
            bool       flag2      = false;
            MapiFolder result;

            try
            {
                byte[]         array      = null;
                MapiEntryId    entryId    = null;
                MapiFolderPath folderPath = null;
                string         legacyDn   = null;
                if (null == identity.MapiEntryId)
                {
                    if (identity.LegacyDistinguishedName != null)
                    {
                        legacyDn = identity.LegacyDistinguishedName;
                        array    = store.GetFolderEntryId(identity.LegacyDistinguishedName);
                    }
                }
                else
                {
                    array = (byte[])identity.MapiEntryId;
                }
                if (array != null)
                {
                    entryId    = new MapiEntryId(array);
                    mapiFolder = (MapiFolder)store.OpenEntry(array);
                    if (parent == null)
                    {
                        parent = (MapiFolder)store.OpenEntry(mapiFolder.GetProp(PropTag.ParentEntryId).GetBytes());
                        flag   = true;
                    }
                }
                else if (null != identity.MapiFolderPath)
                {
                    folderPath = identity.MapiFolderPath;
                    if (parent == null)
                    {
                        mapiFolder = Folder.GetFolderByPath(store, identity.MapiFolderPath, out parent);
                        flag       = true;
                    }
                    else
                    {
                        mapiFolder = Folder.GetFolderByPath(store, parent, identity.MapiFolderPath);
                    }
                }
                if (idCtor != null)
                {
                    realId = idCtor(entryId, folderPath, legacyDn);
                }
                flag2  = true;
                result = mapiFolder;
            }
            finally
            {
                if (!flag2)
                {
                    if (mapiFolder != null)
                    {
                        mapiFolder.Dispose();
                        mapiFolder = null;
                    }
                    if (flag && parent != null)
                    {
                        parent.Dispose();
                        parent = null;
                    }
                }
            }
            return(result);
        }
예제 #16
0
        private static MapiFolder RetrieveParentMapiFolder(MapiStore store, FolderId identity, ref MapiFolder folder)
        {
            if (store == null)
            {
                throw new ArgumentNullException("store");
            }
            Folder.CheckRequirementsOnIdentityToContinue(identity);
            MapiFolder mapiFolder = null;
            bool       flag       = false;
            bool       flag2      = false;
            MapiFolder result;

            try
            {
                byte[] array = null;
                if (null == identity.MapiEntryId)
                {
                    if (identity.LegacyDistinguishedName != null)
                    {
                        array = store.GetFolderEntryId(identity.LegacyDistinguishedName);
                    }
                }
                else
                {
                    array = (byte[])identity.MapiEntryId;
                }
                if (array != null)
                {
                    if (folder == null)
                    {
                        folder = (MapiFolder)store.OpenEntry(array);
                        flag   = true;
                    }
                    mapiFolder = (MapiFolder)store.OpenEntry(folder.GetProp(PropTag.ParentEntryId).GetBytes());
                }
                else if (null != identity.MapiFolderPath)
                {
                    MapiFolderPath parent = identity.MapiFolderPath.Parent;
                    if (null == parent)
                    {
                        mapiFolder = store.GetRootFolder();
                    }
                    else
                    {
                        mapiFolder = Folder.GetFolderByPath(store, parent);
                    }
                }
                flag2  = true;
                result = mapiFolder;
            }
            finally
            {
                if (!flag2)
                {
                    if (flag && folder != null)
                    {
                        folder.Dispose();
                        folder = null;
                    }
                    if (mapiFolder != null)
                    {
                        mapiFolder.Dispose();
                        mapiFolder = null;
                    }
                }
            }
            return(result);
        }
예제 #17
0
 internal PublicFolderId(MapiEntryId entryId, MapiFolderPath folderPath, string legacyDn) : base(new PublicStoreId(), entryId, folderPath, legacyDn)
 {
 }
예제 #18
0
 internal FolderId(MessageStoreId storeId, MapiEntryId entryId, MapiFolderPath folderPath, string legacyDn) : base(entryId)
 {
     this.messageStoreId          = storeId;
     this.mapiFolderPath          = folderPath;
     this.legacyDistinguishedName = legacyDn;
 }
예제 #19
0
 public PublicFolderId(MapiFolderPath folderPath) : base(new PublicStoreId(), folderPath)
 {
 }
예제 #20
0
        private static MapiFolderPath GetFolderPath(MapiEntryId folderEntryId, MapiFolder mapiFolder, MapiStore mapiStore)
        {
            MapiFolderPath result;

            try
            {
                if (null == folderEntryId)
                {
                    if (mapiFolder == null)
                    {
                        throw new ArgumentNullException("mapiFolder");
                    }
                    PropValue prop = mapiFolder.GetProp(PropTag.EntryId);
                    if (PropType.Error == prop.PropType)
                    {
                        return(null);
                    }
                    folderEntryId = new MapiEntryId(prop.GetBytes());
                }
                if (mapiStore == null)
                {
                    throw new ArgumentNullException("mapiStore");
                }
                MapiEntryId operand;
                using (MapiFolder rootFolder = mapiStore.GetRootFolder())
                {
                    operand = new MapiEntryId(rootFolder.GetProp(PropTag.EntryId).GetBytes());
                }
                MapiEntryId    operand2         = new MapiEntryId(mapiStore.GetIpmSubtreeFolderEntryId());
                MapiEntryId    operand3         = new MapiEntryId(mapiStore.GetNonIpmSubtreeFolderEntryId());
                MapiFolderPath mapiFolderPath   = null;
                MapiEntryId    mapiEntryId      = folderEntryId;
                MapiEntryId    mapiEntryId2     = null;
                string         parentFolderName = null;
                while (!(operand2 == mapiEntryId))
                {
                    if (operand3 == mapiEntryId || operand == mapiEntryId)
                    {
                        mapiFolderPath = MapiFolderPath.GenerateFolderPath("NON_IPM_SUBTREE", mapiFolderPath, true);
                    }
                    else
                    {
                        using (MapiFolder mapiFolder2 = (MapiFolder)mapiStore.OpenEntry((byte[])mapiEntryId))
                        {
                            PropValue[] props = mapiFolder2.GetProps(new PropTag[]
                            {
                                PropTag.ParentEntryId,
                                PropTag.DisplayName
                            });
                            if (PropType.Error == props[0].PropType || PropType.Error == props[1].PropType)
                            {
                                return(null);
                            }
                            mapiEntryId2     = new MapiEntryId(props[0].GetBytes());
                            parentFolderName = props[1].GetString();
                        }
                        if (!(mapiEntryId2 == mapiEntryId))
                        {
                            mapiFolderPath = MapiFolderPath.GenerateFolderPath(parentFolderName, mapiFolderPath, false);
                            mapiEntryId    = mapiEntryId2;
                            continue;
                        }
                    }
IL_19C:
                    return(mapiFolderPath);
                }
                mapiFolderPath = MapiFolderPath.GenerateFolderPath("IPM_SUBTREE", mapiFolderPath, true);
                goto IL_19C;
            }
            catch (MapiPermanentException)
            {
                result = null;
            }
            catch (MapiRetryableException)
            {
                result = null;
            }
            return(result);
        }
예제 #21
0
 public FolderId(MessageStoreId storeId, MapiFolderPath folderPath)
 {
     this.messageStoreId = storeId;
     this.mapiFolderPath = folderPath;
 }
예제 #22
0
 internal MailboxFolderId(ADObjectId mailboxOwnerId, StoreObjectId storeObjectId, MapiFolderPath folderPath) : base(mailboxOwnerId)
 {
     if (null == folderPath && storeObjectId == null)
     {
         throw new ArgumentException(ServerStrings.ErrorNoStoreObjectIdAndFolderPath);
     }
     this.StoreObjectIdValue = storeObjectId;
     this.MailboxFolderPath  = folderPath;
 }
예제 #23
0
 internal override void Save(bool keepUnmanagedResources)
 {
     if (ObjectState.Unchanged == base.ObjectState)
     {
         return;
     }
     if (ObjectState.Deleted == base.ObjectState)
     {
         throw new MapiInvalidOperationException(Strings.ExceptionObjectStateInvalid(base.ObjectState.ToString()));
     }
     base.EnableDisposeTracking();
     using (MapiStore messageStore = this.GetMessageStore())
     {
         MapiFolder mapiFolder        = null;
         MapiFolder parentFolder      = null;
         bool       isFolderRetrieved = false;
         try
         {
             MapiSession mapiSession = base.MapiSession;
             Folder.CheckRequirementsOnSessionToContinue(base.MapiSession);
             bool creating = false;
             if (base.ObjectState == ObjectState.New)
             {
                 creating = true;
                 string text = null;
                 if (this.newFolderIdentity == null)
                 {
                     if (null == this.Identity)
                     {
                         throw new MapiInvalidOperationException(Strings.ExceptionIdentityNull);
                     }
                     if (null == this.Identity.MapiFolderPath)
                     {
                         throw new MapiInvalidOperationException(Strings.ExceptionIdentityInvalid);
                     }
                     MapiFolder mapiFolder2 = null;
                     try
                     {
                         parentFolder = Folder.RetrieveParentMapiFolder(messageStore, this.Identity, ref mapiFolder2);
                     }
                     finally
                     {
                         if (mapiFolder2 != null)
                         {
                             mapiFolder2.Dispose();
                         }
                     }
                     if (parentFolder != null && !parentFolder.AllowWarnings)
                     {
                         parentFolder.AllowWarnings = true;
                     }
                     text = this.Identity.MapiFolderPath.Name;
                 }
                 else
                 {
                     this.Identity = this.ConstructIdentity(null, MapiFolderPath.GenerateFolderPath(this.newFolderIdentity.ParentIdentity.MapiFolderPath, this.newFolderIdentity.FolderName, false), null);
                     parentFolder  = Folder.RetrieveMapiFolder(messageStore, this.newFolderIdentity.ParentIdentity);
                     if (parentFolder != null && !parentFolder.AllowWarnings)
                     {
                         parentFolder.AllowWarnings = true;
                     }
                     text = this.newFolderIdentity.FolderName;
                 }
                 ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Create Folder '{0}' on server '{1}'.", this.Identity, base.MapiSession.ServerName);
                 try
                 {
                     mapiFolder = parentFolder.CreateFolder(text, string.Empty, false);
                     if (mapiFolder != null && !mapiFolder.AllowWarnings)
                     {
                         mapiFolder.AllowWarnings = true;
                     }
                     isFolderRetrieved = true;
                 }
                 catch (MapiExceptionCollision innerException)
                 {
                     this.DetectFolderExistence(messageStore, parentFolder, text, innerException);
                     throw;
                 }
                 this.UpdateIdentity(this.UpdateIdentityFlagsForCreating);
             }
             if (creating || ObjectState.Changed == base.ObjectState)
             {
                 Folder.CheckRequirementsOnIdentityToContinue(this.Identity);
                 this.DetectDisallowedModification(messageStore);
                 if (ObjectState.Changed == base.ObjectState && base.IsChanged(MapiPropertyDefinitions.Name))
                 {
                     string name = (string)this[MapiPropertyDefinitions.Name];
                     if (parentFolder == null)
                     {
                         MapiFolder mapiFolder3 = null;
                         try
                         {
                             parentFolder = Folder.RetrieveParentMapiFolder(messageStore, this.Identity, ref mapiFolder3);
                         }
                         finally
                         {
                             if (mapiFolder3 != null)
                             {
                                 mapiFolder3.Dispose();
                             }
                         }
                     }
                     this.DetectFolderExistence(messageStore, parentFolder, name, null);
                 }
                 PropProblem[] array    = null;
                 PropProblem[] array2   = null;
                 FolderId      folderId = null;
                 if (mapiFolder != null)
                 {
                     mapiFolder.Dispose();
                     mapiFolder = null;
                 }
                 mapiFolder = Folder.RetrieveMapiFolder(messageStore, this.Identity, ref parentFolder, new Folder.IdentityConstructor(this.ConstructIdentity), out folderId);
                 ParameterlessReturnlessDelegate parameterlessReturnlessDelegate = delegate()
                 {
                     if (creating && isFolderRetrieved)
                     {
                         ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Remove Folder '{0}' for rolling back creating on server '{1}'.", this.Identity, this.MapiSession.ServerName);
                         try
                         {
                             parentFolder.DeleteFolder((byte[])this.Identity.MapiEntryId);
                         }
                         catch (MapiRetryableException ex)
                         {
                             ExTraceGlobals.FolderTracer.TraceError <FolderId, string, string>((long)this.GetHashCode(), "Removing Folder '{0}' for rolling back caughting an exception on server '{1}': {2}", this.Identity, this.MapiSession.ServerName, ex.Message);
                         }
                         catch (MapiPermanentException ex2)
                         {
                             ExTraceGlobals.FolderTracer.TraceError <FolderId, string, string>((long)this.GetHashCode(), "Removing Folder '{0}' for rolling back caughting an exception on server '{1}': {2}", this.Identity, this.MapiSession.ServerName, ex2.Message);
                         }
                     }
                 };
                 try
                 {
                     PropValue[] propertyValuesToUpdate = base.GetPropertyValuesToUpdate();
                     if (0 < propertyValuesToUpdate.Length)
                     {
                         ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Set PropValues against Folder '{0}' on server '{1}'.", this.Identity, base.MapiSession.ServerName);
                         array = mapiFolder.SetProps(propertyValuesToUpdate);
                     }
                     PropTag[] propertyTagsToDelete = base.GetPropertyTagsToDelete();
                     if (0 < propertyTagsToDelete.Length)
                     {
                         ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string>((long)this.GetHashCode(), "To Delete PropTags against Folder '{0}' on server '{1}'.", this.Identity, base.MapiSession.ServerName);
                         array2 = mapiFolder.DeleteProps(propertyTagsToDelete);
                     }
                 }
                 catch (DataValidationException)
                 {
                     parameterlessReturnlessDelegate();
                     throw;
                 }
                 catch (MapiRetryableException)
                 {
                     parameterlessReturnlessDelegate();
                     throw;
                 }
                 catch (MapiPermanentException)
                 {
                     parameterlessReturnlessDelegate();
                     throw;
                 }
                 base.ResetChangeTrackingAndObjectState();
                 StringBuilder stringBuilder = new StringBuilder();
                 if (array != null && 0 < array.Length)
                 {
                     stringBuilder.AppendLine(Strings.ErrorSetPropsProblem(this.Identity.ToString(), array.Length.ToString()));
                     foreach (PropProblem propProblem in array)
                     {
                         stringBuilder.Append('\t');
                         stringBuilder.AppendLine(Strings.ErrorPropProblem(propProblem.PropTag.ToString(), propProblem.PropType.ToString(), propProblem.Scode.ToString()));
                     }
                     stringBuilder.AppendLine();
                 }
                 if (array2 != null && 0 < array2.Length)
                 {
                     stringBuilder.AppendLine(Strings.ErrorDeletePropsProblem(this.Identity.ToString(), array2.Length.ToString()));
                     foreach (PropProblem propProblem2 in array2)
                     {
                         stringBuilder.Append('\t');
                         stringBuilder.Append(Strings.ErrorPropProblem(propProblem2.PropTag.ToString(), propProblem2.PropType.ToString(), propProblem2.Scode.ToString()));
                         stringBuilder.AppendLine();
                     }
                     stringBuilder.AppendLine();
                 }
                 if (0 < stringBuilder.Length)
                 {
                     string text2 = stringBuilder.ToString();
                     ExTraceGlobals.FolderTracer.TraceDebug <FolderId, string, string>((long)this.GetHashCode(), "Setting Folder '{0}' on server '{1}' returns error '{2}'.", this.Identity, base.MapiSession.ServerName, text2);
                     parameterlessReturnlessDelegate();
                     throw new MapiInvalidOperationException(new LocalizedString(text2));
                 }
             }
         }
         finally
         {
             if (mapiFolder != null)
             {
                 mapiFolder.Dispose();
             }
             if (parentFolder != null)
             {
                 parentFolder.Dispose();
             }
             base.Dispose();
         }
     }
 }
예제 #24
0
        internal static MapiFolder GetFolderByPath(MapiStore mapiStore, MapiFolderPath folderPath, out MapiFolder parent)
        {
            if (mapiStore == null)
            {
                throw new ArgumentNullException("mapiStore");
            }
            if (null == folderPath)
            {
                throw new ArgumentNullException("folderPath");
            }
            parent = null;
            MapiFolder mapiFolder = null;
            bool       flag       = false;
            MapiFolder result;

            try
            {
                mapiFolder = (folderPath.IsIpmPath ? mapiStore.GetIpmSubtreeFolder() : mapiStore.GetNonIpmSubtreeFolder());
                int num = 0;
                while (folderPath.Depth - 1 > num)
                {
                    MapiFolder mapiFolder2;
                    parent = (mapiFolder2 = mapiFolder);
                    using (mapiFolder2)
                    {
                        mapiFolder = parent.OpenSubFolderByName(folderPath[num]);
                    }
                    num++;
                }
                if (folderPath.Depth - 1 == num)
                {
                    if (parent != null)
                    {
                        parent.Dispose();
                        parent = null;
                    }
                    parent     = mapiFolder;
                    mapiFolder = parent.OpenSubFolderByName(folderPath[num]);
                }
                if (parent == null)
                {
                    parent = mapiStore.GetRootFolder();
                }
                flag   = true;
                result = mapiFolder;
            }
            finally
            {
                if (!flag)
                {
                    if (mapiFolder != null)
                    {
                        mapiFolder.Dispose();
                        mapiFolder = null;
                    }
                    if (parent != null)
                    {
                        parent.Dispose();
                        parent = null;
                    }
                }
            }
            return(result);
        }
예제 #25
0
        // Token: 0x06000B23 RID: 2851 RVA: 0x00023C30 File Offset: 0x00021E30
        internal PublicFolderIdParameter(string publicFolderIdString, bool isEntryId)
        {
            if (string.IsNullOrEmpty(publicFolderIdString))
            {
                throw new ArgumentNullException("publicFolderIdString");
            }
            this.rawIdentity = publicFolderIdString;
            PublicFolderId publicFolderId = null;

            try
            {
                int num = publicFolderIdString.IndexOf('\\');
                if (num < 0)
                {
                    if (isEntryId)
                    {
                        publicFolderId = new PublicFolderId(StoreObjectId.FromHexEntryId(publicFolderIdString));
                    }
                }
                else if (num == 0)
                {
                    if (publicFolderIdString.Length > 1 && publicFolderIdString[num + 1] == '\\')
                    {
                        throw new FormatException(Strings.ErrorIncompletePublicFolderIdParameter(publicFolderIdString));
                    }
                    publicFolderId = new PublicFolderId(MapiFolderPath.Parse(publicFolderIdString));
                }
                else
                {
                    if (!MapiTaskHelper.IsDatacenter)
                    {
                        throw new FormatException(Strings.ErrorIncompletePublicFolderIdParameter(publicFolderIdString));
                    }
                    if (num == publicFolderIdString.Length - 1)
                    {
                        throw new FormatException(Strings.ErrorIncompleteDCPublicFolderIdParameter(publicFolderIdString));
                    }
                    this.Organization = new OrganizationIdParameter(publicFolderIdString.Substring(0, num));
                    if (publicFolderIdString[num + 1] == '\\')
                    {
                        publicFolderId = new PublicFolderId(MapiFolderPath.Parse(publicFolderIdString.Substring(num + 1)));
                    }
                    else if (isEntryId)
                    {
                        publicFolderId = new PublicFolderId(StoreObjectId.FromHexEntryId(publicFolderIdString.Substring(num + 1)));
                    }
                }
            }
            catch (FormatException innerException)
            {
                throw new FormatException(MapiTaskHelper.IsDatacenter ? Strings.ErrorIncompleteDCPublicFolderIdParameter(this.rawIdentity) : Strings.ErrorIncompletePublicFolderIdParameter(this.rawIdentity), innerException);
            }
            catch (CorruptDataException innerException2)
            {
                throw new FormatException(MapiTaskHelper.IsDatacenter ? Strings.ErrorIncompleteDCPublicFolderIdParameter(this.rawIdentity) : Strings.ErrorIncompletePublicFolderIdParameter(this.rawIdentity), innerException2);
            }
            if (publicFolderId != null)
            {
                ((IIdentityParameter)this).Initialize(publicFolderId);
            }
        }
예제 #26
0
 internal static MapiFolder GetFolderByPath(MapiStore mapiStore, MapiFolder parentFolder, MapiFolderPath folderPath)
 {
     if (null == folderPath)
     {
         throw new ArgumentNullException("folderPath");
     }
     if (folderPath.IsSubtreeRoot)
     {
         if (mapiStore == null)
         {
             throw new ArgumentNullException("mapiStore");
         }
         if (!folderPath.IsIpmPath)
         {
             return(mapiStore.GetNonIpmSubtreeFolder());
         }
         return(mapiStore.GetIpmSubtreeFolder());
     }
     else
     {
         if (parentFolder == null)
         {
             throw new ArgumentNullException("parentFolder");
         }
         return(parentFolder.OpenSubFolderByName(folderPath[folderPath.Depth - 1]));
     }
 }
예제 #27
0
 internal PublicFolderId(OrganizationId organizationId, StoreObjectId storeObjectId, MapiFolderPath folderPath) : this(storeObjectId, folderPath)
 {
     this.OrganizationId = organizationId;
 }
예제 #28
0
 internal PublicFolderId(MapiFolderPath folderPath)
 {
     this.MapiFolderPath = folderPath;
 }