public PrimaryHierarchyAclModifyTable(RPCPrimaryHierarchyProvider primaryHierarchyProvider, CoreFolder coreFolder, IModifyTable permissionsTable, ModifyTableOptions options)
 {
     this.coreFolder = coreFolder;
     this.options    = options;
     this.primaryHierarchyProvider = primaryHierarchyProvider;
     this.currentPermissionsTable  = permissionsTable;
 }
示例#2
0
        public StoreId CreateFolder(string folderName, string folderDescription, StoreId parentFolderId, CreateMode mode, out Guid contentMailboxGuid)
        {
            StoreId result;

            using (PublicFolderConnectionLimitsTracker.Instance.GetToken(this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn))
            {
                StoreSession storeSession = null;
                object       thisObject   = null;
                bool         flag         = false;
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.BeginMapiCall();
                        storeSession.BeginServerHealthCall();
                        flag = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    using (MapiStore hierarchyStore = this.GetHierarchyStore())
                    {
                        using (MapiFolder mapiFolder = (MapiFolder)hierarchyStore.OpenEntry(this.GetDestinationSpecificEntryId(hierarchyStore, parentFolderId)))
                        {
                            using (MapiFolder mapiFolder2 = mapiFolder.CreateFolder(folderName, folderDescription, mode == CreateMode.OpenIfExists))
                            {
                                contentMailboxGuid = RPCPrimaryHierarchyProvider.GetMailboxGuidFromPersonalizedLegacyDN(mapiFolder2.GetReplicaServers()[0]);
                                result             = StoreObjectId.FromProviderSpecificId(mapiFolder2.GetProp(PropTag.EntryId).GetBytes(), StoreObjectType.Folder);
                            }
                        }
                    }
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateFolder(folderName), ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("RPCPrimaryHierarchyProvider.CreateFolder : folderName = {0}", folderName),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateFolder(folderName), ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("RPCPrimaryHierarchyProvider.CreateFolder : folderName = {0}", folderName),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (storeSession != null)
                        {
                            storeSession.EndMapiCall();
                            if (flag)
                            {
                                storeSession.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
            }
            return(result);
        }
示例#3
0
        public void ModifyPermissions(StoreId folderId, AclTableEntry.ModifyOperation[] modifyOperations, ModifyTableOptions options, bool replaceAllRows)
        {
            using (PublicFolderConnectionLimitsTracker.Instance.GetToken(this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn))
            {
                StoreSession storeSession = null;
                object       thisObject   = null;
                bool         flag         = false;
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.BeginMapiCall();
                        storeSession.BeginServerHealthCall();
                        flag = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    using (MapiStore hierarchyStore = this.GetHierarchyStore())
                    {
                        using (MapiFolder mapiFolder = (MapiFolder)hierarchyStore.OpenEntry(this.GetDestinationSpecificEntryId(hierarchyStore, folderId)))
                        {
                            using (MapiModifyTable mapiModifyTable = (MapiModifyTable)mapiFolder.OpenProperty(PropTag.AclTable, InterfaceIds.IExchangeModifyTable, 0, OpenPropertyFlags.DeferredErrors))
                            {
                                GetTableFlags    getTableFlags    = GetTableFlags.None;
                                ModifyTableFlags modifyTableFlags = ModifyTableFlags.None;
                                if (options == ModifyTableOptions.FreeBusyAware)
                                {
                                    getTableFlags    |= GetTableFlags.FreeBusy;
                                    modifyTableFlags |= ModifyTableFlags.FreeBusy;
                                }
                                if (replaceAllRows)
                                {
                                    modifyTableFlags |= ModifyTableFlags.RowListReplace;
                                }
                                using (MapiTable table = mapiModifyTable.GetTable(getTableFlags))
                                {
                                    Dictionary <byte[], long> entryIdToMemberIdMap = RPCPrimaryHierarchyProvider.GetEntryIdToMemberIdMap(table.QueryAllRows(null, RPCPrimaryHierarchyProvider.MapiAclTableColumns));
                                    List <RowEntry>           list = new List <RowEntry>(modifyOperations.Length);
                                    foreach (AclTableEntry.ModifyOperation modifyOperation in modifyOperations)
                                    {
                                        switch (modifyOperation.Operation)
                                        {
                                        case ModifyTableOperationType.Add:
                                            list.Add(RPCPrimaryHierarchyProvider.ConvertToRowEntry(modifyOperation));
                                            break;

                                        case ModifyTableOperationType.Modify:
                                        case ModifyTableOperationType.Remove:
                                        {
                                            AclTableEntry.ModifyOperation modifyOperation2 = modifyOperation;
                                            if (modifyOperation.Entry.MemberId != -1L && modifyOperation.Entry.MemberId != 0L)
                                            {
                                                if (entryIdToMemberIdMap.ContainsKey(modifyOperation.Entry.MemberEntryId))
                                                {
                                                    modifyOperation2 = new AclTableEntry.ModifyOperation(modifyOperation.Operation, new AclTableEntry(entryIdToMemberIdMap[modifyOperation.Entry.MemberEntryId], null, null, modifyOperation.Entry.MemberRights));
                                                }
                                                else if (modifyOperation.Operation == ModifyTableOperationType.Modify)
                                                {
                                                    modifyOperation2 = new AclTableEntry.ModifyOperation(ModifyTableOperationType.Add, new AclTableEntry(0L, modifyOperation.Entry.MemberEntryId, null, modifyOperation.Entry.MemberRights));
                                                }
                                                else
                                                {
                                                    modifyOperation2 = null;
                                                }
                                            }
                                            if (modifyOperation2 != null)
                                            {
                                                list.Add(RPCPrimaryHierarchyProvider.ConvertToRowEntry(modifyOperation2));
                                            }
                                            break;
                                        }
                                        }
                                    }
                                    mapiModifyTable.ModifyTable(modifyTableFlags, list.ToArray());
                                }
                            }
                        }
                    }
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExWrappedStreamFailure, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("RPCPrimaryHierarchyProvider.WriteAclPropertyStream : folderId = {0}", folderId),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExWrappedStreamFailure, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("RPCPrimaryHierarchyProvider.WriteAclPropertyStream : folderId = {0}", folderId),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (storeSession != null)
                        {
                            storeSession.EndMapiCall();
                            if (flag)
                            {
                                storeSession.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
            }
        }
示例#4
0
 public PropProblem[] DeleteProperties(StoreId folderId, PropTag[] propertyTags, out Guid contentMailboxGuid)
 {
     PropProblem[] result;
     using (PublicFolderConnectionLimitsTracker.Instance.GetToken(this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn))
     {
         StoreSession storeSession = null;
         object       thisObject   = null;
         bool         flag         = false;
         try
         {
             if (storeSession != null)
             {
                 storeSession.BeginMapiCall();
                 storeSession.BeginServerHealthCall();
                 flag = true;
             }
             if (StorageGlobals.MapiTestHookBeforeCall != null)
             {
                 StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
             }
             using (MapiStore hierarchyStore = this.GetHierarchyStore())
             {
                 using (MapiFolder mapiFolder = (MapiFolder)hierarchyStore.OpenEntry(this.GetDestinationSpecificEntryId(hierarchyStore, folderId)))
                 {
                     contentMailboxGuid = RPCPrimaryHierarchyProvider.GetMailboxGuidFromPersonalizedLegacyDN(mapiFolder.GetReplicaServers()[0]);
                     result             = mapiFolder.DeleteProps(propertyTags, true);
                 }
             }
         }
         catch (MapiPermanentException ex)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("RPCPrimaryHierarchyProvider.DeleteProperties : folderId = {0}", folderId),
                 ex
             });
         }
         catch (MapiRetryableException ex2)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("RPCPrimaryHierarchyProvider.DeleteProperties : 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);
 }