GetSchema returns too many Views
GetSchema returns too many Views
Hello,
I use the latest version of dotConnect for Oracle. I need to get the names of the Views that belong to the schema related to the user defined in my connection string. I need to do it through LINQ, so i use the DataContext.Connection.GetSchema method.
For now, i don't want to use the schema name restriction, because there is not an elegant way to obtain it. I don't want to use the OracleConnection.UserId property, because ideally i would like to port the application to an other database type like SQL Server when the new LinqConnect product is ready.
Without the schema name restriction, i get lots of system Views like the ones beginning with DBA_ and V_$. Nevertheless, the user has only the CONNECT role and the CREATE SESSION, CREATE SEQUENCE and SELECT ANY TABLE privileges!
Is this possible? I really need to have access only to the Views located under the current schema...
I use the latest version of dotConnect for Oracle. I need to get the names of the Views that belong to the schema related to the user defined in my connection string. I need to do it through LINQ, so i use the DataContext.Connection.GetSchema method.
For now, i don't want to use the schema name restriction, because there is not an elegant way to obtain it. I don't want to use the OracleConnection.UserId property, because ideally i would like to port the application to an other database type like SQL Server when the new LinqConnect product is ready.
Without the schema name restriction, i get lots of system Views like the ones beginning with DBA_ and V_$. Nevertheless, the user has only the CONNECT role and the CREATE SESSION, CREATE SEQUENCE and SELECT ANY TABLE privileges!
Is this possible? I really need to have access only to the Views located under the current schema...
This is a designed behaviour. For more information refer to
http://www.devart.com/dotconnect/oracle ... aData.html
As for obtaining the schema name, you can use the context.Connection.UserId property, this is an appropriate way in the Oracle case.
http://www.devart.com/dotconnect/oracle ... aData.html
As for obtaining the schema name, you can use the context.Connection.UserId property, this is an appropriate way in the Oracle case.
Try to get the database name using the following code:
Code: Select all
string name = dataContext.Mapping.DatabaseName;
If you have changed the database name in runtime, you have an opportunity to take the schema name of the concrete table (if you know the schema it is located in). The following code implements this:
One more apparoach is to execute the query
Code: Select all
db.Mapping.GetTable(typeof(Dept)).TableName.Split('.')[0]
Code: Select all
dataContext.ExecuteQuery("begin :Result := SYS_CONTEXT (''USERENV'', ''CURRENT_SCHEMA''); end;");
Second approach is Oracle specific and as i said before, i need a database agnostic way to obtain the schema/database name.
I have the same feeling for the first approach too...
I think that we somehow missed my original request. Let me phrase it again:
For the LinqConnect product, i would like for the GetSchema method to return, BY DEFAULT, the Views that are under the User (in Oracle) or the Database (in SQL Server) or whatever else is common for MySQL etc. It is incorrect behavior to return ALL the system Views even if the User does not have the relevant privileges, as it breaches the enforced security. I really should not have to provide the schema name in order to get the Views to which i originally set my User to have access to.
If one does not provide a schema name for GetSchema method, then the method should assume that the schema is the one defined in the current connection through the User Id parameter (for Oracle installations)
I have the same feeling for the first approach too...
I think that we somehow missed my original request. Let me phrase it again:
For the LinqConnect product, i would like for the GetSchema method to return, BY DEFAULT, the Views that are under the User (in Oracle) or the Database (in SQL Server) or whatever else is common for MySQL etc. It is incorrect behavior to return ALL the system Views even if the User does not have the relevant privileges, as it breaches the enforced security. I really should not have to provide the schema name in order to get the Views to which i originally set my User to have access to.
If one does not provide a schema name for GetSchema method, then the method should assume that the schema is the one defined in the current connection through the User Id parameter (for Oracle installations)