How to use Kerberos authentication with ODBC driver in C# web application hosted in IIS?

105 views Asked by At

I have a web application that connects to ODBC data source that requires Kerberos authentication. I use System.Data.ODBC to connect to ODBC data source:

using (OdbcConnection connection = new OdbcConnection("DSN=Cloudera_Impala_Prod;Trusted_Connection=yes"))
{
    OdbcCommand command = new OdbcCommand(query, connection);
    connection.Open();
    OdbcDataReader reader = command.ExecuteReader();

    while (reader.Read())
    {
        newrow = dtFix.NewRow();
        newrow[0] = reader[0];
        newrow[1] = reader[1];
        dtFix.Rows.Add(newrow);
    }

    reader.Close();     
    connection.Close();
}

After getting a valid Kerberos ticket using MIT Kerberos Client installed in my local machine, the above code will work when my web application is run locally but not when the web application is published in company server using IIS. 

I have attempted to follow the steps to Set up Kerberos Authentication for a Website in IIS but it doesn't work, the program will throw an exception in 'connection.Open()' as if no valid ticket was found. I am not even sure if the steps in the link is what I'm supposed do to achieve my purpose. I hope somebody can guide me on what to do.

These are the related settings in my local machine & web server:

In local machine
MIT Kerberos Client Principal: [email protected]
Domain account: bnt\Aaron

In web server
Website URL: http://myws01.foo.com/AdminPage
Hostname: myws01
FQDN: myws01.foo.com
Registered SPN: HTTP/myws01.foo.com and HOST/myws01
Domain account: bnt\Aaron
Application authentication in IIS: Windows authentication
App pool provider: Negotiate

My web server is Windows Server 2016 and IIS version is 10.0

0

There are 0 answers