Skip to content

SSPI Support #1186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KingDanx opened this issue Mar 28, 2025 · 1 comment
Open

SSPI Support #1186

KingDanx opened this issue Mar 28, 2025 · 1 comment

Comments

@KingDanx
Copy link

I'm seeking support for connecting to my postgres database via SSPI. I've spent hours trying to find a solution to work with my application and I'm hopeful I do not have to abandon the code and start over in another programing language with postgres SSPI authentication support.

pg_hba.conf example:

Image

My Go database connection example

psqlConnString := fmt.Sprintf("host=%s port=%d dbname='%s' sslmode=disable", d.host, d.port, d.dbname)
database, err := sql.Open("postgres", psqlConnString)
if err != nil {
  fmt.Println(err)
  return err
}

err = database.Ping()
if err != nil {
  return err
}

Returned error :

Error connecting to the database: pq: unknown authentication response: 9

Thank you for viewing my issue. If you need anymore information from me please let me know. Any support or suggestions will be greatly appreciated.

@KingDanx
Copy link
Author

I have found a temporary solution to this by using github.com/alexbrainman/odbc

I had to change my connection string:
Image

I also had to change how some of my returned values were being processed. Previous values that were returned as int64 are now being returned as int32 and previous Boolean values are now being returned as strings "1" or "0":
Image
Image

Hopefully this information is helpful to anyone else seeking SSPI authentication within their Go application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant