Example #1
0
 public void drop_foreign_key()
 {
     Table.Constraints.AddForeignKeyOn("ParentId", "users2", "Id", keyName: "fk_users");
     Table.ExecuteDDL();
     Table = Db.DatabaseTools.GetAlterTableBuilder(TableName);
     Table.Constraints.Drop("fk_users").WithoutOptions().ExecuteDDL();
     Assert.False(Db.DatabaseTools.ConstraintExists("fk_users"));
 }
Example #2
0
 public void drop_foreign_key()
 {
     Table.Constraints.AddForeignKeyOn("ParentId", "users2", "Id", keyName: "fk_users");
     Table.ExecuteDDL();
     Table = Db.DatabaseTools.GetAlterTableBuilder(TableName);
     Table.Constraints.Drop("fk_users").WithoutOptions().ExecuteDDL();
     Assert.False(Db.DatabaseTools.ConstraintExists("fk_users"));
 }
 void IModifyTableRestriction.Enforce(IModifyTable modifyTable, IEnumerable <ModifyTableOperation> changingEntries)
 {
     if (changingEntries == null)
     {
         return;
     }
     this.Enforce(() => this.GetExternalUserPermissions(new MapiAclTableAdapter(modifyTable), from entry in changingEntries
                                                        select AclTableEntry.ModifyOperation.FromModifyTableOperation(entry)));
 }
Example #4
0
 void IModifyTableRestriction.Enforce(IModifyTable modifyTable, IEnumerable <ModifyTableOperation> modifyTableOperations)
 {
     if (modifyTableOperations == null)
     {
         return;
     }
     if (this.session != null && this.session.IsPublicFolderSession && !this.session.IsMoveUser && this.HasCreateOrModifyReplyRule(modifyTableOperations) && !this.coreFolder.IsMailEnabled())
     {
         throw new RuleNotSupportedException(ServerStrings.ReplyRuleNotSupportedOnNonMailPublicFolder);
     }
 }
Example #5
0
 internal void Save(CoreFolder coreFolder)
 {
     this.CheckValid();
     Util.ThrowOnNullArgument(coreFolder, "coreFolder");
     if (this.IsDirty)
     {
         this.EnforceRestriction(coreFolder);
         this.SaveSharingPartnership(coreFolder.Session as MailboxSession);
         using (IModifyTable permissionTable = coreFolder.GetPermissionTable(this.PermissionSet.ModifyTableOptions))
         {
             MapiAclTableAdapter mapiAclTableAdapter = new MapiAclTableAdapter(permissionTable);
             this.AddPermissionEntriesForRemove(mapiAclTableAdapter);
             this.AddPermissionEntriesForAddOrModify(mapiAclTableAdapter);
             mapiAclTableAdapter.ApplyPendingChanges(true);
         }
     }
     this.isInvalid = true;
 }
Example #6
0
 private void UpdateRuleAction(StoreObjectId replytemplateMessageId)
 {
     using (IModifyTable ruleTable = base.Context.CurrentFolder.GetRuleTable(null))
     {
         RuleAction       ruleAction = base.Context.CurrentRule.Actions[base.ActionIndex];
         RuleAction.Reply reply      = (RuleAction.Reply)ruleAction;
         RuleAction[]     value      = new RuleAction[]
         {
             new RuleAction.ReplyAction(reply.UserFlags, RuleActionConverter.MapiReplyFlagsToReplyFlags(reply.Flags), replytemplateMessageId, this.replyTemplateGuid)
         };
         PropValue[] propValues = new PropValue[]
         {
             new PropValue(InternalSchema.RuleId, base.Context.CurrentRule.ID),
             new PropValue(InternalSchema.RuleActions, value)
         };
         ruleTable.ModifyRow(propValues);
         ruleTable.ApplyPendingChanges();
     }
     base.Context.TraceDebug("Successfully updated the rule action with TemplateMessageId and/or Guid");
 }
Example #7
0
 private void LoadFrom(CoreFolder coreFolder)
 {
     using (IModifyTable permissionTable = coreFolder.GetPermissionTable(this.PermissionSet.ModifyTableOptions))
     {
         try
         {
             this.LoadFrom(new MapiAclTableAdapter(permissionTable));
         }
         catch (DataSourceOperationException ex)
         {
             throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, null, "PermissionsTable.LoadFrom. Failed due to directory exception {0}.", new object[]
             {
                 ex
             });
         }
         catch (DataSourceTransientException ex2)
         {
             throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "PermissionsTable.LoadFrom. Failed due to directory exception {0}.", new object[]
             {
                 ex2
             });
         }
     }
 }
Example #8
0
 public IndexEditor(IndexCollection schema, IModifyTable parent) : base(schema)
 {
     _parent = parent;
 }
Example #9
0
 internal MapiAclTableAdapter(IModifyTable modifyTable)
 {
     Util.ThrowOnNullArgument(modifyTable, "modifyTable");
     this.modifyTable = modifyTable;
 }
 public PrimaryHierarchyAclModifyTable(RPCPrimaryHierarchyProvider primaryHierarchyProvider, CoreFolder coreFolder, IModifyTable permissionsTable, ModifyTableOptions options)
 {
     this.coreFolder = coreFolder;
     this.options    = options;
     this.primaryHierarchyProvider = primaryHierarchyProvider;
     this.currentPermissionsTable  = permissionsTable;
 }
Example #11
0
 public CommonAlterTableTests()
 {
     Db = Setup.GetDb(engine: Engine);
     SetupTable();
     Table = Db.DatabaseTools.GetAlterTableBuilder(TableName);
 }
Example #12
0
 public CommonAlterTableTests()
 {
     Db = Setup.GetDb(engine: Engine);
     SetupTable();
     Table = Db.DatabaseTools.GetAlterTableBuilder(TableName);
 }
        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();
                }
            }
        }
Example #14
0
 public ColumnsEditor(TableSchema table, IModifyTable parent) : base(table)
 {
     _table  = table;
     _parent = parent;
 }
Example #15
0
 public ConstraintsEditor(ConstraintsCollection schema, IModifyTable parent) : base(schema)
 {
     _parent = parent;
 }
Example #16
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();
            }
        }