Exemplo n.º 1
0
        public MapiTableWrapper GetTable(GetTableFlags flags)
        {
            MapiTable mapiTable = null;

            this.MapiSession.InvokeWithWrappedException(delegate()
            {
                mapiTable = this.mapiModifyTable.GetTable(GetTableFlags.None);
            }, Strings.ErrorGetMapiTableWithIdentityAndServer(this.mapiObjectId.ToString(), this.MapiSession.ServerName), this.mapiObjectId);
            return(new MapiTableWrapper(mapiTable, this.MapiSession, this.mapiObjectId));
        }
Exemplo n.º 2
0
 PropValueData[][] IFolder.GetACL(SecurityProp secProp)
 {
     if (!this.HasSecurityDescriptor(secProp))
     {
         return(null);
     }
     if (this.Mailbox.ServerVersion >= Server.E15MinVersion)
     {
         MrsTracer.Provider.Warning("MAPI provider does not support GetACL against E15+ mailboxes", new object[0]);
         return(null);
     }
     PropValueData[][] result;
     using (this.Mailbox.RHTracker.Start())
     {
         using (MapiModifyTable mapiModifyTable = (MapiModifyTable)this.Folder.OpenProperty(PropTag.AclTable, InterfaceIds.IExchangeModifyTable, 0, OpenPropertyFlags.DeferredErrors))
         {
             GetTableFlags getTableFlags = GetTableFlags.DeferredErrors;
             if (secProp == SecurityProp.FreeBusyNTSD)
             {
                 getTableFlags |= GetTableFlags.FreeBusy;
             }
             using (MapiTable table = mapiModifyTable.GetTable(getTableFlags))
             {
                 PropTag[] propTags = new PropTag[]
                 {
                     PropTag.EntryId,
                     PropTag.MemberId,
                     PropTag.MemberRights,
                     PropTag.MemberName
                 };
                 table.SeekRow(BookMark.Beginning, 0);
                 PropValue[][]     array  = MapiUtils.QueryAllRows(table, null, propTags);
                 PropValueData[][] array2 = new PropValueData[array.Length][];
                 int num = 0;
                 foreach (PropValue[] a in array)
                 {
                     array2[num++] = DataConverter <PropValueConverter, PropValue, PropValueData> .GetData(a);
                 }
                 result = array2;
             }
         }
     }
     return(result);
 }
Exemplo n.º 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());
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public IQueryResult GetQueryResult(QueryFilter queryFilter, ICollection <PropertyDefinition> columns)
        {
            this.CheckDisposed(null);
            Util.ThrowOnNullArgument(columns, "columns");
            GetTableFlags getTableFlags = GetTableFlags.None;

            if ((this.options & ModifyTableOptions.FreeBusyAware) == ModifyTableOptions.FreeBusyAware)
            {
                getTableFlags |= GetTableFlags.FreeBusy;
            }
            IQueryResult result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                MapiTable    mapiTable    = null;
                StoreSession storeSession = this.session;
                object       thisObject   = null;
                bool         flag         = false;
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.BeginMapiCall();
                        storeSession.BeginServerHealthCall();
                        flag = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    mapiTable = this.mapiModifyTable.GetTable(getTableFlags);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetMapiTable, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("PropertyTable.GetQueryResult. Failed to get the MapiTable from the MapiModifyTable.", new object[0]),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetMapiTable, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("PropertyTable.GetQueryResult. Failed to get the MapiTable from the MapiModifyTable.", new object[0]),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (storeSession != null)
                        {
                            storeSession.EndMapiCall();
                            if (flag)
                            {
                                storeSession.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                disposeGuard.Add <MapiTable>(mapiTable);
                QueryExecutor.SetTableFilter(this.session, this.propertyReference, mapiTable, queryFilter);
                QueryResult queryResult = new QueryResult(mapiTable, columns, null, this.session, true);
                disposeGuard.Success();
                result = queryResult;
            }
            return(result);
        }