Reputation: 1977
I am trying to connect to a Oracle database by using the Windows Identity Token, it worked yesterday but today it doesn't and I dont know why.
This is my code:
string ssoConnectionString;
var user = CreateSSOConnectionString(connectionStringBuilder, out ssoConnectionString);
oracleConnectionStringBuilder = new OracleConnectionStringBuilder
{
UserID = user.Identity.Name,
ConnectionString = ssoConnectionString
};
private WindowsPrincipal CreateSSOConnectionString(IConnectionStringBuilder connectionStringBuilder, out string ssoConnectionString)
{
var user = new WindowsPrincipal(WindowsIdentity.GetCurrent());
ssoConnectionString = ConfigurationManager.AppSettings["SSOConnectionString"];
ssoConnectionString = string.Format(ssoConnectionString, connectionStringBuilder.Host);
return user;
}
Connection = new Oracle.DataAccess.Client.OracleConnection();
Connection.ConnectionString = oracleConnectionString.ConnectionString;
Connection.Open(); //Fails on this line
The Code doesn't exactly look like this, but it's the essentials.
The SSO ConnectionString is located in app.config and looks like this:
<add key="SSOConnectionString" value="DATA SOURCE={0};User Id=/;" />
Here is a link showing how Oracle them selves explain how to do it: http://docs.oracle.com/cd/E11882_01/win.112/e18754/featConnecting.htm#i1006432
This is the error message I get:
ORA-1017: invalid username/password; logon denied
I have checked with breakpoints and everything looks fine. I've also searched alot around for this error and most people say it's because of password becoming case sensitive in Oracle version 11g, but I'm not providing any password.
Upvotes: 0
Views: 2095
Reputation: 1977
What caused this error was actually a mismatch between the Oracle.DataAccess.dll
version and the Oracle Client installed on my machine.
So the error is actually not at all related to the code or connection string in the configuration file.
Check your Oracle Client version by writing "sqlplus" in a command window, check that the Oracle.DataAccess.dll
version and target .NET framework version matches.
Upvotes: 1