I have a project which connects (just fine) to Oracle via ODAC, Oracle.DataAccess.Client
in .NET. I would like to switch it to use Oracle.ManagedDataAccess.Client
, but it gives an error ORA-01017: invalid username/password; logon denied
. I know the error happens when I connect/login as a "Proxy User", because it works (no error) when I remove the proxy user info from my connection string, but then I can't use the tables, SPs, packages that I need.
As a developer I need to login with "Proxy User" to impersonate several different back-end jobs, because I can't/won't get the passwords for those accounts. The (proxy/impersonate) technique works nicely with un-managed DataAccess
(which is a big pain to support) but I can't get it to work with ManagedDataAccess
.
Here is my code:
static void Main(string[] args)
{ // I need to impersonate the [reportbot] account to use that schema
string constr = "User Id=developer2[reportbot];Password=Wysiwyg.12345;Data Source=ProdJobDb;";
string ProviderName = "Oracle.ManagedDataAccess.Client";
DbProviderFactory factory = DbProviderFactories.GetFactory(ProviderName);
using (DbConnection conn = factory.CreateConnection())
{
try
{
conn.ConnectionString = constr;
conn.Open();
//run SPs that [ReportBot] has access to, but dev contractor accounts don't
}
catch (Exception ex)
{
Console.WriteLine(ex.Message); //breakpoint here F9
Console.WriteLine(ex.StackTrace);
}
}
}
This link suggest the following connection string
// Connecting using proxy authentication
con.ConnectionString = "User Id=scott;Password=tiger;" +
"Data Source=oracle;Proxy User Id=appserver;Proxy Password=eagle; ";
Based on your input is
real user reportbot (you have no password)
proxy user developer2 (you have password)
so the connection string to be used is
"User Id=reportbot;Proxy User Id=developer2;Proxy Password=<your delevoper pwd>;Data Source=ProdJobDb;";