Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 862537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:09:32+00:00 2026-05-15T09:09:32+00:00

I use ADO.NET from C# 4 in order to set up a test context

  • 0

I use ADO.NET from C# 4 in order to set up a test context for a component.

I execute the following SQL as sysdba:

new[]
{
    "create user \"{0}\" identified externally default tablespace USER_DATA temporary tablespace TEMP profile DEFAULT"
    .FormatWith( Config.QualifiedUserName ),
    "create role {0}"
    .FormatWith( Config.RoleName ),
    "grant {0} to \"{1}\""
    .FormatWith( Config.RoleName, Config.QualifiedUserName ),
    "insert into doc.application( id, name ) values( {0}, '{1}' )"
    .FormatWith( Config.AppId, Config.AppName ),
    "insert into doc.appl_role( application, role, description ) values( {0}, '{1}', '{2}' )"
    .FormatWith( Config.AppId, Config.RoleName, Config.RoleDescription ),
    "create table {0}.{1} ( ID number primary key, VERSION number, NAME varchar(100) )"
    .FormatWith( Config.TestSchema, Config.TestTable ),
    "insert into {0}.{1} (ID, VERSION, NAME) values ('{2}', '{3}', '{4}')"
    .FormatWith( Config.TestSchema, Config.TestTable, Config.TestRowId, 1, Config.TestRowName ),
    "grant select, insert, update, delete on {0}.{1} to {2}"
    .FormatWith( Config.TestSchema, Config.TestTable, Config.RoleName ),
    "grant create session to \"{0}\""
    .FormatWith( Config.QualifiedUserName )
} 

and the Config class looks like so:

public struct Config
{
    public const Int32 TestRowId = 1;
    public const Int32 AppId = 99999;
    public const String AppName = "OraceUtils";
    public const String RoleName = "ORACLE_UTILS_BASE";
    public static readonly String RoleDescription = "For testing {0}".FormatWith( AppName );
    public static readonly String QualifiedUserName = @"{0}\{1}".FormatWith( Domain, UserName );
    public const String DataSource = "TESTDB";
    public const String Domain = "BI";
    public const String UserName = "ORACLE_TEST_USER";
    public const String UserPassword = [for my eyes only];
    public const String TestSchema = "CI";
    public const String TestTable = "ROLE_PROVIDER_TEST_TABLE";
    public const String TestRowName = "Arne And";
}

From what I’ve read, just granting a role to a user doesn’t enable it. However, after executing the SQL above, the user BI\ORACLE_TEST_USER can use the table ROLE_PROVIDER_TEST_TABLE just fine. The role ORACLE_UTILS_BASE also shows in SESSION_ROLES.

If I issue “SET ROLES” afterwards, the aforementioned user can’t access the table.

I thought it was the other way around, i.e. that the user wouldn’t have access until she issues “SET ROLES ORACLE_UTILS_BASE, [any other roles]”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:09:33+00:00Added an answer on May 15, 2026 at 9:09 am

    When a user connects to the DB, all their default roles are enabled. You can change which roles are defaults with the synthax:

    ALTER USER <user> DEFAULT ROLE <role>
    

    <role> can be either a role name or the keywords ALL or NONE

    When you grant a role to a user it becomes a default role (i-e the user doesn’t have to activate it with SET ROLE <role> when they connect).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

currently I use DataSet to read data from ADO.NET SQL provider, but I read
I'm trying to use: // this is a BreakHistory class from the ADO.NET Data
I'm trying to use a view to create an ADO.NET entity using a view.
I'm trying to run a query from ADO.NET using SQL Server 2008R2. I'm using
I want to use ADO.net to extract some data from an Excel file. This
When I used to use ADO.NET, I used to create TableAdapters which were populated
I'm trying to use the Task-Parallel-Library to offload expensive ADO.NET database access from the
At university, we were given task to use ADO.NET or LINQ to SQL and
Using: ado.net How can I select data from a DataTable using SQL with an
The Goal Use an ADO.NET IDbConnection and IDbCommand to execute multiple commands at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.