如何配置 PostgreSQL 以使用 Windows 身份验证?

发布于 2024-09-14 04:47:23 字数 333 浏览 1 评论 0原文

我正在尝试设置 PostgreSQL 并只允许某些 Windows 用户访问数据库中的数据。使用 MS SQL 设置 Windows 身份验证非常简单,但我不知道如何在 PostgreSQL 中设置它。

我已经浏览了 http://www.postgresql.org/ 上的文档docs/current/static/auth-methods.html

并编辑 pg_hba 文件。但这样做后,PostgreSQL服务无法启动。

I am trying to setup PostgreSQL and allow only certain Windows users to access the data from the database. Setting up Windows Authentication is Quite easy with MS SQL, but I can't figure out how to set it up in PostgreSQL.

I have gone through the documentation at http://www.postgresql.org/docs/current/static/auth-methods.html

and edited the pg_hba file. But after doing so, the PostgreSQL service fails to start.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心碎的声音 2024-09-21 04:47:23

Postgresql 服务器和客户端都在 Windows 上运行吗,那么您可以对此进行测试以查看是否有效:

host all all 0.0.0.0/0 sspi

Magnus Hagander,Postgresql 开发人员,详细说明

“从本地计算机、您的域或受信任域连接的所有用户都将使用配置的 SSPI 自动进行身份验证身份验证(您可以使用组策略启用/禁用 NTLMv2 或 LM 等功能 - 这是 Windows 配置,而不是 PostgreSQL 配置)。您仍然需要在 PostgreSQL 中创建登录角色,但仅此而已,请注意,域未在以下位置进行验证。所有,仅用户名。因此,如果您的主域和受信任域中的用户管理员尝试连接到 PostgreSQL,则它们将被视为同一用户。请注意,此方法与 Unix 客户端不兼容。”

如果您混合使用 Unix-Windows,那么您必须使用 GSSAPI 求助于 kerberos,这意味着您必须进行一些配置。 这篇关于在 Windows 环境中部署 Pg 的文章也许会引导你走上正确的道路。

Is the Postgresql server running on Windows as well as the clients then you might test with this to see if this works:

host all all 0.0.0.0/0 sspi

Magnus Hagander, a Postgresql developer, elaborates on this:

"All users connecting from the local machine, your domain, or a trusted domain will be automatically authenticated using the SSPI configured authentication (you can enable/disable things like NTLMv2 or LM using Group Policy - it's a Windows configuration, not a PostgreSQL one). You still need to create the login role in PostgreSQL, but that's it. Note that the domain is not verified at all, only the username. So the user Administrator in your primary and a trusted domain will be considered the same user if they try to connect to PostgreSQL. Note that this method is not compatible with Unix clients."

If you mix Unix-Windows then you have to resort to kerberos using GSSAPI which means you have to do some configuration. This article on deploying Pg in Windows environments may perhaps lead you in the right path.

不如归去 2024-09-21 04:47:23

如果其他人像我一样从 9.5 开始遇到这种情况,您将需要向 ipv4 和 ipv6 添加一个可选参数,以便使其正常工作

include_realm=0

所以整个事情看起来像

host all your_username 127.0.0.1/32 sspi include_realm=0

If anyone else encouters this like I did so starting from 9.5 you wil need to add an optional parameter both to the ipv4 and ipv6 in order for this to work

include_realm=0

so the whole thing will look like

host all your_username 127.0.0.1/32 sspi include_realm=0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文