Esempio n. 1
0
        PropValueData[][] IFolder.GetACL(SecurityProp secProp)
        {
            MrsTracer.Provider.Function("StorageFolder.GetACL: {0}", new object[]
            {
                this.DisplayNameForTracing
            });
            if (!this.HasSecurityDescriptor(secProp))
            {
                return(null);
            }
            ModifyTableOptions options = (secProp == SecurityProp.FreeBusyNTSD) ? ModifyTableOptions.FreeBusyAware : ModifyTableOptions.None;

            return(this.GetAcl(options, StorageFolder.AclTableColumns));
        }
Esempio n. 2
0
        PropValueData[][] IFolder.GetExtendedAcl(AclFlags aclFlags)
        {
            MrsTracer.Provider.Function("StorageFolder.GetExtendedAcl: flags = {0}, {1}", new object[]
            {
                aclFlags,
                this.DisplayNameForTracing
            });
            if (!this.HasSecurityDescriptor(aclFlags))
            {
                return(null);
            }
            ModifyTableOptions modifyTableOptions = aclFlags.HasFlag(AclFlags.FreeBusyAcl) ? ModifyTableOptions.FreeBusyAware : ModifyTableOptions.None;

            modifyTableOptions |= ModifyTableOptions.ExtendedPermissionInformation;
            return(this.GetAcl(modifyTableOptions, StorageFolder.ExtendedAclTableColumns));
        }
Esempio n. 3
0
 internal AclModifyTable(CoreFolder coreFolder, ModifyTableOptions options, IModifyTableRestriction modifyTableRestriction, bool useSecurityDescriptorOnly, bool loadTableEntries)
 {
     using (DisposeGuard disposeGuard = this.Guard())
     {
         this.coreFolder                = coreFolder;
         this.options                   = options;
         this.modifyTableRestriction    = modifyTableRestriction;
         this.recipientSession          = coreFolder.Session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid);
         this.useSecurityDescriptorOnly = useSecurityDescriptorOnly;
         if (loadTableEntries)
         {
             this.Load();
         }
         else
         {
             this.replaceAllRows = true;
         }
         disposeGuard.Success();
     }
 }
Esempio n. 4
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());
                        }
                    }
                }
            }
        }
 public PrimaryHierarchyAclModifyTable(RPCPrimaryHierarchyProvider primaryHierarchyProvider, CoreFolder coreFolder, IModifyTable permissionsTable, ModifyTableOptions options)
 {
     this.coreFolder = coreFolder;
     this.options    = options;
     this.primaryHierarchyProvider = primaryHierarchyProvider;
     this.currentPermissionsTable  = permissionsTable;
 }
Esempio n. 6
0
 internal PropertyTable(CoreFolder coreFolder, NativeStorePropertyDefinition property, ModifyTableOptions options, IModifyTableRestriction modifyTableRestriction)
 {
     Util.ThrowOnNullArgument(coreFolder, "coreFolder");
     Util.ThrowOnNullArgument(property, "property");
     EnumValidator.ThrowIfInvalid <ModifyTableOptions>(options);
     using (DisposeGuard disposeGuard = this.Guard())
     {
         this.mapiModifyTable        = PropertyTable.GetMapiModifyTable(coreFolder, property);
         this.session                = coreFolder.Session;
         this.propertyReference      = this.session.Mailbox.MapiStore;
         this.tableNameForTracing    = property.Name;
         this.options                = options;
         this.modifyTableRestriction = modifyTableRestriction;
         disposeGuard.Success();
     }
 }
Esempio n. 7
0
 internal AclModifyTable(CoreFolder coreFolder, ModifyTableOptions options, IModifyTableRestriction modifyTableRestriction, bool useSecurityDescriptorOnly) : this(coreFolder, options, modifyTableRestriction, useSecurityDescriptorOnly, true)
 {
 }
        void IDestinationFolder.SetACL(SecurityProp secProp, PropValueData[][] aclData)
        {
            MrsTracer.Provider.Function("StorageDestinationFolder.SetACL: {0}, isNullAcl: {1}", new object[]
            {
                base.DisplayNameForTracing,
                aclData == null
            });
            if (aclData == null)
            {
                return;
            }
            ModifyTableOptions options = (secProp == SecurityProp.FreeBusyNTSD) ? ModifyTableOptions.FreeBusyAware : ModifyTableOptions.None;

            using (IModifyTable permissionTable = base.CoreFolder.GetPermissionTable(options))
            {
                permissionTable.Clear();
                foreach (PropValueData[] array in aclData)
                {
                    long?        num          = null;
                    byte[]       array2       = null;
                    MemberRights memberRights = MemberRights.None;
                    foreach (PropValueData propValueData in array)
                    {
                        int propTag = propValueData.PropTag;
                        if (propTag != 268370178)
                        {
                            if (propTag != 1718681620)
                            {
                                if (propTag == 1718812675)
                                {
                                    memberRights = (MemberRights)propValueData.Value;
                                }
                            }
                            else
                            {
                                num = new long?((long)propValueData.Value);
                            }
                        }
                        else
                        {
                            array2 = (byte[])propValueData.Value;
                        }
                    }
                    PropValue[] array3 = new PropValue[2];
                    array3[0] = new PropValue(PermissionSchema.MemberRights, memberRights);
                    if (num != null && (num.Value == 0L || num.Value == -1L))
                    {
                        array3[1] = new PropValue(PermissionSchema.MemberId, num);
                        permissionTable.ModifyRow(array3);
                    }
                    else if (array2 != null)
                    {
                        array3[1] = new PropValue(PermissionSchema.MemberEntryId, array2);
                        permissionTable.AddRow(array3);
                    }
                }
                using (base.Mailbox.RHTracker.Start())
                {
                    permissionTable.ApplyPendingChanges();
                }
            }
        }
Esempio n. 9
0
        public override void Apply(CoreFolder folder)
        {
            if (this.Value == null)
            {
                return;
            }
            ModifyTableOptions modifyTableOptions = this.Flags.HasFlag(AclFlags.FreeBusyAcl) ? ModifyTableOptions.FreeBusyAware : ModifyTableOptions.None;

            modifyTableOptions |= ModifyTableOptions.ExtendedPermissionInformation;
            using (IModifyTable permissionTableDoNotLoadEntries = folder.GetPermissionTableDoNotLoadEntries(modifyTableOptions))
            {
                foreach (PropValueData[] array in this.Value)
                {
                    List <PropValue> list = new List <PropValue>();
                    int j = 0;
                    while (j < array.Length)
                    {
                        PropValueData propValueData = array[j];
                        int           propTag       = propValueData.PropTag;
                        if (propTag <= 1718747166)
                        {
                            if (propTag != 268370178)
                            {
                                if (propTag != 1718681620)
                                {
                                    if (propTag != 1718747166)
                                    {
                                        goto IL_168;
                                    }
                                    list.Add(new PropValue(PermissionSchema.MemberName, (string)propValueData.Value));
                                }
                            }
                            else
                            {
                                byte[] array2 = (byte[])propValueData.Value;
                                if (array2 != null)
                                {
                                    list.Add(new PropValue(PermissionSchema.MemberEntryId, array2));
                                }
                            }
                        }
                        else if (propTag != 1718812675)
                        {
                            if (propTag != 1718878466)
                            {
                                if (propTag != 1718943755)
                                {
                                    goto IL_168;
                                }
                                list.Add(new PropValue(PermissionSchema.MemberIsGroup, (bool)propValueData.Value));
                            }
                            else
                            {
                                list.Add(new PropValue(PermissionSchema.MemberSecurityIdentifier, (byte[])propValueData.Value));
                            }
                        }
                        else
                        {
                            list.Add(new PropValue(PermissionSchema.MemberRights, (MemberRights)propValueData.Value));
                        }
IL_191:
                        j++;
                        continue;
IL_168:
                        MrsTracer.Provider.Warning("StorageDestinationFolder.SetAcl: Unknown PropTag 0x{0:x}", new object[]
                        {
                            propValueData.PropTag
                        });
                        goto IL_191;
                    }
                    permissionTableDoNotLoadEntries.AddRow(list.ToArray());
                }
                permissionTableDoNotLoadEntries.ApplyPendingChanges();
            }
        }