Re: Can't input username into sspi odbcconnection - Mailing list pgsql-odbc

From Lindsay Stevens
Subject Re: Can't input username into sspi odbcconnection
Date
Msg-id CAG2CW_JBYkt4DYjVTwUrnua6q7u5zvRY62u-C_jFsJ+Z_xZvCg@mail.gmail.com
Whole thread Raw
In response to Can't input username into sspi odbcconnection  (Branden Huggins <branden.huggins@rockwellcollins.com>)
List pgsql-odbc

Pretty sure SSPI gets done by libpq so instead you could try using PGUSER set as a process level (or higher) environment variable.

In my regular use of SSPI the Uid param is never specified anywhere - not even envars as PGUSER - it just knows..!


On 24 Nov 2016 9:40 am, "Branden Huggins" <branden.huggins@rockwellcollins.com> wrote:
Anytime I input any username into the connection string for an Odbc connectionstring when using SSPI, I get and AccessViolationException.
Is there a way to generate the extra @NETWORK without inputting a username?
or
Can I change something to make the uid string take an input without throwing an acception?

pg_hba.conf:

host   all   all   127.0.0.1/32   sspi   include_realm=1
host   all   all   ::1/128   sspi   include_realm=1

Connection String:

"Driver={PostgreSQL Unicode};Trusted_Connection=yes;uid=bwhuggin@CCANET;database=hostdb-4.2.0;server=localhost;port=5432;"

Simple Code:

 try
         {
            using (OdbcConnection connection = new OdbcConnection(odbc_connection_string))
            {
               connection.Open();
            }
         }
         catch (Exception ex)
         {
            System.Diagnostics.Trace.WriteLine("Connection problem: " + ex);
            odbc = false;
       }

Result:

Connection problem: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Data.Common.UnsafeNativeMethods.SQLDriverConnectW(OdbcConnectionHandle hdbc, IntPtr hwnd, String connectionstring, Int16 cbConnectionstring, IntPtr connectionstringout, Int16 cbConnectionstringoutMax, Int16& cbConnectionstringout, Int16 fDriverCompletion)
   at System.Data.Odbc.OdbcConnectionHandle.Connect(String connectionString)
   at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
   at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
   at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.Odbc.OdbcConnection.Open()
   at ConsoleApplication1.Program.TestMethod(String connectionMethod) in 
2012\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 86

pgsql-odbc by date:

Previous
From: "Inoue, Hiroshi"
Date:
Subject: Re: error conection Provider=MSDASQL
Next
From: Adrian Klaver
Date:
Subject: Re: Regarding postgres client on windows