public void RemoveTableDescription(Table table, DbObjectType objectType) => RunSql($@"EXEC sys.sp_dropextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = @schema, @level1type = N'{objectType}', @level1name = @table" , new SqlParameter("@schema", table.SchemaName), new SqlParameter("@table", table.TableName));
public ResourceAccessSecurityAssert(ObjectName resourceName, DbObjectType resourceType, Privileges privileges) { ResourceName = resourceName; ResourceType = resourceType; Privileges = privileges; Arguments = new InvokeArgument[0]; }
public static IDbObject GetObject(this IQueryContext context, DbObjectType objType, ObjectName objName, AccessType accessType) { // First handle the special cases of cursors and variable, that can be declared // in a query context // If they are declared in the context, the user owns them and we don't need // to verify the ownership if (objType == DbObjectType.Cursor) { var obj = context.FindCursor(objName.Name); if (obj != null) { return(obj); } } else if (objType == DbObjectType.Variable) { var obj = context.FindVariable(objName.Name); if (obj != null) { return(obj); } } // TODO: throw a specialized exception if (!context.UserCanAccessObject(objType, objName)) { throw new InvalidOperationException(); } return(context.Session().GetObject(objType, objName, accessType)); }
public DataDefinitionObject(DataDefinitionType defType, DbObjectType objType, DdlConfiguration conf = null) { _definitionType = defType; _objectType = objType; _configuration = conf; }
public virtual bool DropObject(DbObjectType objectType, ObjectName objectName) { //if (!Session.User.CanDrop(objectType, objectName)) // throw new MissingPrivilegesException(Session.User.Name, objectName, Privileges.Drop); return(Session.Transaction.DropObject(objectType, objectName)); }
private Privileges QueryGroupPrivileges(string groupName, DbObjectType objectType, ObjectName objectName, bool withOption, bool withPublic) { var grantTable = QueryContext.GetTable(SystemSchema.GroupGrantsTable); return(QueryPrivileges(QueryContext, grantTable, groupName, objectType, objectName, withOption, withPublic)); }
public View(string name, string owner, DbConnector db, bool isMaterialized, DbObjectType DbObjectTypeName) : base(name, owner, db, DbObjectTypeName) { Columns = new List <Column>(); AddColumns(db); AddCardinality(db); IsMaterialized = isMaterialized; }
public DbObjectKey(object catalog, object schema, object name, DbObjectType objectType) { if (catalog != null && !Convert.IsDBNull(catalog)) { _catalog = catalog.ToString(); } else { _catalog = null; } if (schema != null && !Convert.IsDBNull(schema)) { _schema = schema.ToString(); } else { _schema = null; } if (name != null && !Convert.IsDBNull(name)) { _name = name.ToString(); } else { _name = null; } _objectType = objectType; Debug.Assert(_catalog != null || _schema != null || _name != null, "This is going to look like an empty one, just ue the default constructor"); }
private IEnumerable <ISearchTarget> CreateObjectBasedSearchTarget(DbObject[] dbObjects, ILookup <long, DbColumn> dbColumnsByTableId) { var list = new List <ISearchTarget>(); foreach (var dbObject in dbObjects) { var simplifiedType = DbObjectType.Parse(dbObject.Type); if (simplifiedType.Category == DbSimplifiedType.Constraint) { list.Add(new ConstraintSearchTarget(dbObject)); } else if (simplifiedType.Category == DbSimplifiedType.Table) { list.Add(new TableSearchTarget(dbObject, dbColumnsByTableId[dbObject.ObjectId].ToArray())); } else if (simplifiedType.Category == DbSimplifiedType.Other) { list.Add(new OtherSearchTarget(dbObject)); } else { list.Add(new ObjectSearchTarget(dbObject)); } } return(list); }
public override bool HasPrivileges(DbObjectType objectType, ObjectName objectName, Privileges privileges) { if (IsSecureAccess) return true; return base.HasPrivileges(objectType, objectName, privileges); }
public static void AddObjectManager <TManager>(this IScope scope, DbObjectType objectType) where TManager : class, IDbObjectManager { scope.Register <IDbObjectManager, TManager>(objectType); scope.Register <IDbObjectManager, TManager>(); scope.Register <TManager>(); }
//public void RevokeAllGrantsOn(DbObjectType objectType, ObjectName objectName) { // using (var query = Session.CreateQuery()) { // var grantTable = query.Access.GetMutableTable(SystemSchema.GrantsTableName); // var privBitCol = grantTable.GetResolvedColumnName(0); // var objectTypeColumn = grantTable.GetResolvedColumnName(1); // var objectNameColumn = grantTable.GetResolvedColumnName(2); // var granteeCol = grantTable.GetResolvedColumnName(3); // var grantOptionCol = grantTable.GetResolvedColumnName(4); // var granterCol = grantTable.GetResolvedColumnName(5); // // All that match the given object // var t1 = grantTable.SimpleSelect(query, objectTypeColumn, SqlExpressionType.Equal, // SqlExpression.Constant(Field.Integer((int) objectType))); // // All that match the given parameter // t1 = t1.SimpleSelect(query, objectNameColumn, SqlExpressionType.Equal, // SqlExpression.Constant(Field.String(objectName.FullName))); // // Remove these rows from the table // grantTable.Delete(t1); // } //} public Grant[] GetGrantsOn(DbObjectType objectType, ObjectName objectName) { using (var query = Session.CreateQuery()) { var grantTable = query.Access().GetMutableTable(SystemSchema.GrantsTableName); var objectTypeColumn = grantTable.GetResolvedColumnName(1); var objectNameColumn = grantTable.GetResolvedColumnName(2); // All that match the given object var t1 = grantTable.SimpleSelect(query, objectTypeColumn, SqlExpressionType.Equal, SqlExpression.Constant(Field.Integer((int)objectType))); // All that match the given parameter t1 = t1.SimpleSelect(query, objectNameColumn, SqlExpressionType.Equal, SqlExpression.Constant(Field.String(objectName.FullName))); var list = new List <Grant>(); foreach (var row in t1) { var priv = (Privileges)((SqlNumber)row.GetValue(0).Value).ToInt32(); var grantee = row.GetValue(3); var grantOption = row.GetValue(4); var granter = row.GetValue(5); list.Add(new Grant(priv, objectName, objectType, grantee, granter, grantOption)); } return(list.ToArray()); } }
private Privileges QueryUserPrivileges(string userName, DbObjectType objectType, ObjectName objectName, bool withOption, bool withPublic) { // The system grants table. var grantTable = QueryContext.GetTable(SystemSchema.UserGrantsTableName); return(QueryPrivileges(QueryContext, grantTable, userName, objectType, objectName, withOption, withPublic)); }
public GrantQuery(DbObjectType objType, ObjectName objName, string userName, int flags) : this() { this.objType = objType; this.objName = objName; this.userName = userName; this.flags = flags; }
/// <summary> /// Constructs a new event with the given object name and type. /// </summary> /// <param name="objectName">The <see cref="ObjectName"/> that uniquely identify the /// object created.</param> /// <param name="objectType">The <see cref="DbObjectType"/> of the object created.</param> /// <exception cref="ArgumentNullException"> /// If the given <paramref name="objectName"/> parameter passed is <c>null</c>. /// </exception> public ObjectCreatedEvent(ObjectName objectName, DbObjectType objectType) { if (objectName == null) throw new ArgumentNullException("objectName"); ObjectName = objectName; ObjectType = objectType; }
public IDbFirst Where(DbObjectType dbObjectType) { if (dbObjectType != DbObjectType.All) { this.TableInfoList = this.TableInfoList.Where(it => it.DbObjectType == dbObjectType).ToList(); } return(this); }
public void UpdateTableDescription(Table table, string description, DbObjectType objectType) => RunSql($@"EXEC sp_updateextendedproperty @name = N'MS_Description', @value = @desc, @level0type = N'Schema', @level0name = @schema, @level1type = N'{objectType}', @level1name = @table" , new SqlParameter("@schema", table.SchemaName), new SqlParameter("@table", table.TableName), new SqlParameter("@desc", description));
private static Privileges QueryPrivileges(IQuery queryContext, ITable grantTable, string grantee, DbObjectType objectType, ObjectName objectName, bool withOption, bool withPublic) { var objectCol = grantTable.GetResolvedColumnName(1); var paramCol = grantTable.GetResolvedColumnName(2); var granteeCol = grantTable.GetResolvedColumnName(3); var grantOptionCol = grantTable.GetResolvedColumnName(4); var granterCol = grantTable.GetResolvedColumnName(5); ITable t1 = grantTable; // All that match the given object parameter // It's most likely this will reduce the search by the most so we do // it first. t1 = t1.SimpleSelect(queryContext, paramCol, SqlExpressionType.Equal, SqlExpression.Constant(Field.String(objectName.FullName))); // The next is a single exhaustive select through the remaining records. // It finds all grants that match either public or the grantee is the // user or role, and that match the object type. // Expression: ("grantee_col" = grantee OR "grantee_col" = 'public') var granteeCheck = SqlExpression.Equal(SqlExpression.Reference(granteeCol), SqlExpression.Constant(Field.String(grantee))); if (withPublic) { granteeCheck = SqlExpression.Or(granteeCheck, SqlExpression.Equal(SqlExpression.Reference(granteeCol), SqlExpression.Constant(Field.String(User.PublicName)))); } // Expression: ("object_col" = object AND // ("grantee_col" = grantee OR "grantee_col" = 'public')) // All that match the given grantee or public and given object var expr = SqlExpression.And(SqlExpression.Equal(SqlExpression.Reference(objectCol), SqlExpression.Constant(Field.BigInt((int)objectType))), granteeCheck); // Are we only searching for grant options? if (withOption) { var grantOptionCheck = SqlExpression.Equal(SqlExpression.Reference(grantOptionCol), SqlExpression.Constant(Field.BooleanTrue)); expr = SqlExpression.And(expr, grantOptionCheck); } t1 = t1.ExhaustiveSelect(queryContext, expr); // For each grant, merge with the resultant priv object Privileges privs = Privileges.None; foreach (var row in t1) { var priv = (int)row.GetValue(0).AsBigInt(); privs |= (Privileges)priv; } return(privs); }
public void AddName(DbObjectType objectType, string name) { if (names.ContainsKey(objectType)) { throw new Exception("Yous can't add an objectType multiple times"); } names.Add(objectType, name); }
public string GetObjectName(DbObjectType objectType) { if (!names.ContainsKey(objectType)) { throw new Exception("Yous should provide a value for all DbObjectType"); } return(names[objectType]); }
public override bool HasGrantOption(DbObjectType objectType, ObjectName objectName, Privileges privileges) { if (IsSecureAccess) { return(true); } return(base.HasGrantOption(objectType, objectName, privileges)); }
public void RemoveColumnDescription(TableColumn tableColumn, DbObjectType objectType) => RunSql($@"EXEC sys.sp_dropextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = @schema, @level1type = N'{objectType}', @level1name = @table, @level2type = N'Column', @level2name = @column" , new SqlParameter("@schema", tableColumn.SchemaName), new SqlParameter("@table", tableColumn.TableName), new SqlParameter("@column", tableColumn.ColumnName));
private Privileges QueryUserPrivileges(string userName, DbObjectType objectType, ObjectName objectName, bool withOption, bool withPublic) { using (var query = Session.CreateQuery()) { // The system grants table. var grantTable = query.Access().GetTable(SystemSchema.GrantsTableName); return(QueryPrivileges(query, grantTable, userName, objectType, objectName, withOption, withPublic)); } }
private void UpdateUserGrants(DbObjectType objectType, ObjectName objectName, string granter, string grantee, Privileges privileges, bool withOption) { using (var query = Session.CreateQuery()) { var grantTable = query.Access().GetMutableTable(SystemSchema.GrantsTableName); UpdateGrants(query, grantTable, objectType, objectName, granter, grantee, privileges, withOption); } }
} //used for recording DBModel change scripts in the database public DbModelObjectBase(DbModel dbModel, string schema, DbObjectType objectType, HashedObject entityModelObject = null) { DbModel = dbModel; Schema = GlobalName = schema; ObjectType = objectType; if (DbModel != null && entityModelObject != null) { DbModel.RegisterDbObject(entityModelObject, this); } }
private void UpdateUserGrants(DbObjectType objectType, ObjectName objectName, string granter, string grantee, Privileges privileges, bool withOption) { var grantTable = QueryContext.GetMutableTable(SystemSchema.UserGrantsTableName); try { UpdateGrants(QueryContext, grantTable, objectType, objectName, granter, grantee, privileges, withOption); } finally { ClearUserGrantsCache(grantee, objectType, objectName, withOption, true); } }
public ObjectCreatedEvent(IEventSource source, DbObjectType objectType, ObjectName objectName) : base(source) { if (ObjectName.IsNullOrEmpty(objectName)) { throw new ArgumentNullException(nameof(objectName)); } ObjectType = objectType; ObjectName = objectName; }
/// <summary> /// Constructs a new event with the given object name and type. /// </summary> /// <param name="objectName">The <see cref="ObjectName"/> that uniquely identify the /// object created.</param> /// <param name="objectType">The <see cref="DbObjectType"/> of the object created.</param> /// <exception cref="ArgumentNullException"> /// If the given <paramref name="objectName"/> parameter passed is <c>null</c>. /// </exception> public ObjectCreatedEvent(ObjectName objectName, DbObjectType objectType) { if (objectName == null) { throw new ArgumentNullException("objectName"); } ObjectName = objectName; ObjectType = objectType; }
public static async Task <IDbObject> GetObjectAsync(this IContext context, DbObjectType objectType, ObjectName objectName) { var manager = context.GetObjectManager(objectType); if (manager == null) { return(null); } return(await manager.GetObjectAsync(objectName)); }
public bool HasGrantOption(string granter, DbObjectType objectType, ObjectName objectName, Privileges privileges) { if (User.IsSystemUserName(granter)) { return(true); } var privs = GetPrivileges(granter, objectType, objectName, true); return((privs & privileges) != 0); }
public static async Task <bool> ObjectExistsAsync(this IContext context, DbObjectType objectType, ObjectName objectName) { var manager = context.GetObjectManager(objectType); if (manager == null) { return(false); } return(await manager.ObjectExistsAsync(objectName)); }
public static IDbObject GetObject(this ITransaction transaction, DbObjectType objType, ObjectName objName) { var manager = transaction.GetObjectManager(objType); if (manager == null) { return(null); } return(manager.GetObject(objName)); }
public void GrantOn(DbObjectType objectType, ObjectName objectName, string grantee, Privileges privileges, bool withOption = false) { try { var granter = Session.User.Name; var grant = new Grant(privileges, objectName, objectType, grantee, granter, withOption); PrivilegeManager.Grant(grant); } finally { PrivilegesCache.Remove(new GrantCacheKey(grantee, objectType, objectName.FullName, withOption, false)); } }
/// <summary> /// Constructs a new grant for an user on the given /// object, including the privileges of the grant. /// </summary> /// <param name="privileges">The access privileges granted to the user on the /// given object.</param> /// <param name="objectName">The fully qualified name of the object on which /// to grant the given access privileges to the user.</param> /// <param name="objectType">The <see cref="DbObjectType">type of the object</see>.</param> /// <param name="granterName">The name of the user that granted.</param> /// <param name="withOption"></param> public Grant(Privileges privileges, ObjectName objectName, DbObjectType objectType, string granterName, bool withOption) { if (String.IsNullOrEmpty(granterName)) throw new ArgumentNullException("granterName"); if (objectName == null) throw new ArgumentNullException("objectName"); Privileges = privileges; ObjectName = objectName; ObjectType = objectType; GranterName = granterName; WithOption = withOption; }
public DbObjectChange(DbModelObjectBase oldObject, DbModelObjectBase newObject, DbObjectChangeType? changeType = null, string notes = null) { var obj = newObject ?? oldObject; Util.Check(obj != null, "Fatal error in DbModelChange constructor: oldObject and newObject are both null."); ObjectType = obj.ObjectType; OldObject = oldObject; NewObject = newObject; Notes = notes; if(changeType == null) ChangeType = newObject == null ? DbObjectChangeType.Drop : (oldObject == null ? DbObjectChangeType.Add : DbObjectChangeType.Modify); else ChangeType = changeType.Value; }
/// <summary> /// Constructs a new grant for the given user on the given /// object, including the privileges of the grant. /// </summary> /// <param name="userName">The name of the user holding the grant.</param> /// <param name="privileges">The access privileges granted to the user on the /// given object.</param> /// <param name="objectName">The fully qualified name of the object on which /// to grant the given access privileges to the user.</param> /// <param name="objectType">The <see cref="DbObjectType">type of the object</see>.</param> /// <param name="granterName">The name of the user that granted.</param> public UserGrant(string userName, Privileges privileges, ObjectName objectName, DbObjectType objectType, string granterName) { if (String.IsNullOrEmpty(userName)) throw new ArgumentNullException("userName"); if (String.IsNullOrEmpty(granterName)) throw new ArgumentNullException("granterName"); if (objectName == null) throw new ArgumentNullException("objectName"); UserName = userName; Privileges = privileges; ObjectName = objectName; ObjectType = objectType; GranterName = granterName; }
public static bool DropObject(this IQueryContext context, DbObjectType objectType, ObjectName objectName) { if (objectType == DbObjectType.Variable && context.DropVariable(objectName.Name)) { return true; } if (objectType == DbObjectType.Cursor && context.DropCursor(objectName.Name)) { return true; } if (!context.UserCanDropObject(objectType, objectName)) throw new MissingPrivilegesException(context.UserName(), objectName, Privileges.Drop); context.Session().DropObject(objectType, objectName); return true; }
public virtual bool HasPrivileges(DbObjectType objectType, ObjectName objectName, Privileges privileges) { AssertInContext(); if (Session.Access().UserHasPrivilege(Name, objectType, objectName, privileges)) return true; var obj = Session.Access().GetObject(objectType, objectName); if (obj != null && String.Equals(Name, obj.ObjectInfo.Owner)) return true; if (objectName.Parent != null) return HasPrivileges(DbObjectType.Schema, objectName.Parent, privileges); return false; }
public static IDbUpgradeScript NewDbModelChangeScript(this IDbUpgradeBatch batch, DbObjectChangeType changeType, DbObjectType objectType, string fullObjectName, string sql, int executionOrder, int subOrder, int duration, Exception exception) { var session = EntityHelper.GetSession(batch); var ent = session.NewEntity<IDbUpgradeScript>(); ent.Batch = batch; ent.ObjectType = objectType; ent.FullObjectName = fullObjectName; ent.ExecutionOrder = executionOrder; ent.SubOrder = subOrder; ent.Sql = sql; ent.Duration = duration; if(exception != null) ent.Errors = exception.ToLogString(); return ent; }
static public string GetObjectCreate(MySqlConnector conn, DbObjectType type, string objectName, bool ifNotExists) { string resultColumn = ""; switch (type) { case DbObjectType.PROCEDURE: resultColumn = "Create Procedure"; break; case DbObjectType.FUNCTION: resultColumn = "Create Function"; break; case DbObjectType.EVENT: resultColumn = "Create Event"; break; case DbObjectType.VIEW: resultColumn = "Create View"; break; case DbObjectType.TABLE: resultColumn = "Create Table"; break; } string sql = string.Format(@"SHOW CREATE {0} {1}", type.ToString(), objectName); using (DataReaderBase reader = conn.ExecuteReader(sql)) { while (reader.Read()) { string create = StringFromDb(reader[resultColumn]); if (ifNotExists && create != null && create.StartsWith(@"CREATE TABLE")) { create = @"CREATE TABLE IF NOT EXISTS" + create.Substring(@"CREATE TABLE".Length); } return create; } } return null; }
public static IDbObject GetObject(this IQueryContext context, DbObjectType objType, ObjectName objName, AccessType accessType) { // First handle the special cases of cursors and variable, that can be declared // in a query context // If they are declared in the context, the user owns them and we don't need // to verify the ownership if (objType == DbObjectType.Cursor) { var obj = context.FindCursor(objName.Name); if (obj != null) return obj; } else if (objType == DbObjectType.Variable) { var obj = context.FindVariable(objName.Name); if (obj != null) return obj; } // TODO: throw a specialized exception if (!context.UserCanAccessObject(objType, objName)) throw new InvalidOperationException(); return context.Session().GetObject(objType, objName, accessType); }
public IObjectManager ResolveForType(DbObjectType objType) { if (objType == DbObjectType.Schema) return transaction.schemaManager; if (objType == DbObjectType.Table) return transaction.tableManager; if (objType == DbObjectType.Sequence) return transaction.sequenceManager; if (objType == DbObjectType.Variable) return transaction.variableManager; if (objType == DbObjectType.View) return transaction.viewManager; if (objType == DbObjectType.Trigger) return transaction.triggerManager; return null; }
public static void DropObject(this ISession session, DbObjectType objectType, ObjectName objectName) { session.Transaction.DropObject(objectType, objectName); }
public static ObjectName ResolveObjectName(this ITransaction transaction, DbObjectType objectType, ObjectName objectName) { var manager = transaction.GetObjectManager(objectType); if (manager == null) return objectName; return manager.ResolveName(objectName, transaction.IgnoreIdentifiersCase()); }
internal static IObjectManager GetObjectManager(this ITransaction transaction, DbObjectType objectType) { return transaction.Context.ResolveService<IObjectManager>(objectType); }
public static IDbObject GetObject(this ITransaction transaction, DbObjectType objType, ObjectName objName) { var manager = transaction.GetObjectManager(objType); if (manager == null) return null; return manager.GetObject(objName); }
public static bool RealObjectExists(this ITransaction transaction, DbObjectType objType, ObjectName objName) { var manager = transaction.GetObjectManager(objType); if (manager == null) return false; return manager.RealObjectExists(objName); }
public DbModelObjectBase(DbModel dbModel, string schema, DbObjectType objectType, HashedObject entityModelObject = null) { DbModel = dbModel; Schema = GlobalName = schema; ObjectType = objectType; if (DbModel != null && entityModelObject != null) DbModel.RegisterDbObject(entityModelObject, this); }
// internal for testing internal void CreateEntitySets( IEnumerable<TableDetailsRow> tableDetailsRows, EntityRegister entityRegister, IList<EntitySet> entitySetsForReadOnlyEntityTypes, DbObjectType objectType) { Debug.Assert(tableDetailsRows != null, "tableDetailsRows != null"); Debug.Assert(entityRegister != null, "entityRegister != null"); Debug.Assert(entitySetsForReadOnlyEntityTypes != null, "entitySetsForReadOnlyEntityTypes != null"); Debug.Assert( objectType == DbObjectType.Table || objectType == DbObjectType.View, "Unexpected object type - only tables and views are supported"); foreach (var tableDetailsRowsForTable in SplitRows(tableDetailsRows)) { var firstRow = tableDetailsRowsForTable[0]; bool needsDefiningQuery; var entityType = CreateEntityType(tableDetailsRowsForTable, out needsDefiningQuery); entityRegister.AddEntityType(firstRow.GetMostQualifiedTableName(), entityType); // skip EntitySet creation for invalid entity types. We still need the types themselves - they // will be written to the ssdl in comments for informational and debugging purposes. if (!MetadataItemHelper.IsInvalid(entityType)) { var entitySet = EntitySet.Create( entityType.Name, !firstRow.IsSchemaNull() ? firstRow.Schema : null, firstRow.TableName != entityType.Name ? firstRow.TableName : null, null, entityType, new[] { CreateStoreModelBuilderMetadataProperty( TypeAttributeName, objectType == DbObjectType.Table ? TablesTypeAttributeValue : ViewsTypeAttributeValue) }); if (needsDefiningQuery) { entitySetsForReadOnlyEntityTypes.Add(entitySet); } else { entityRegister.AddEntitySet(entitySet); } } } }
static public List<string> GetObjectList(MySqlConnector conn, DbObjectType type) { string sql = null; switch (type) { case DbObjectType.TABLE: sql = @"SHOW TABLES"; break; default: sql = string.Format(@"SHOW {0} STATUS", type.ToString()); break; } List<string> lstResults = new List<string>(); using (DataReaderBase reader = conn.ExecuteReader(sql)) { while (reader.Read()) { switch (type) { case DbObjectType.TABLE: lstResults.Add(reader.GetStringOrEmpty(0)); break; default: lstResults.Add((string)reader[@"Name"]); break; } } } return lstResults; }
public static bool ObjectExists(this ITransaction transaction, DbObjectType objType, ObjectName objName) { var manager = transaction.Managers.ResolveForType(objType); if (manager == null) return false; return manager.ObjectExists(objName); }
public static ObjectName ResolveObjectName(this ISession session, DbObjectType objectType, ObjectName objectName) { return session.Transaction.ResolveObjectName(objectType, objectName); }
public static bool ObjectExists(this ISession session, DbObjectType objectType, ObjectName objectName) { return session.Transaction.ObjectExists(objectType, objectName); }
public static IDbObject GetObject(this ISession session, DbObjectType objectType, ObjectName objectName, AccessType accessType) { var obj = session.Transaction.GetObject(objectType, objectName); if (obj != null) session.Access(obj, accessType); return obj; }
public override bool HasGrantOption(DbObjectType objectType, ObjectName objectName, Privileges privileges) { if (IsSystem) return true; if (base.HasGrantOption(objectType, objectName, privileges)) return true; var roles = Roles; if (roles == null || roles.Length == 0) return false; return roles.Any(role => role.HasGrantOption(objectType, objectName, privileges)); }
public override bool HasPrivileges(DbObjectType objectType, ObjectName objectName, Privileges privileges) { if (IsSystem || IsInRole(SystemRoles.SecureAccessRole)) return true; if (base.HasPrivileges(objectType, objectName, privileges)) return true; var roles = Roles; if (roles == null || roles.Length == 0) return false; return roles.Any(role => role.HasPrivileges(objectType, objectName, privileges)); }
public static IDbObject GetObject(this ISession session, DbObjectType objectType, ObjectName objectName) { return GetObject(session, objectType, objectName, AccessType.ReadWrite); }
public DbTableInfo(DbModel model, string schema, string tableName, EntityInfo entity, DbObjectType objectType = DbObjectType.Table) : base(model, schema, objectType, entity) { TableName = tableName; Entity = entity; //might be null Kind = EntityKind.Table; if (Entity != null) Kind = Entity.Kind; else if (objectType == DbObjectType.View) Kind = EntityKind.View; // when loading from database FullName = model.Driver.GetFullName(Schema, tableName); base.GlobalName = DbModelHelper.GetGlobalName(Schema, TableName); model.AddTable(this); }