I have a windows c++ application which uses libpq to work with PostgreSQL.

My code is:

std::string conninfo = "host=localhost port=5432 dbname=test connect_timeout=10";
_connectionHandlerPtr = PQconnectdb(conninfo.c_str());

Now I need to use MIT Kerberos for authentication. I installed MIT Kerberos.

What I need to do in my code? What I need to change in PostgreSQL config?

有帮助吗?

解决方案

I don't think you need to change anything in your code. A quick look at psql suggests that all the Kerberos support is handled via libpq, so psql doesn't have to care; the same should be true of your app.

If your system is set up for Kerberos auth and has a ticket, you should just need to set krbsrvname in your libpq connection string. See the libpq parameters. On Windows you may also need to set gsslib to gssapi if you want to use MIT Kerberos instead of SSPI.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top