简体   繁体   English

如何在 SQL Server (ODBC) 中使用 mod_authn_dbd

[英]How to use mod_authn_dbd with SQL Server (ODBC)

There are many tutorial for using mod_authn_dbd with MySQL but I could not find any with SQL Server using ODBC.有很多关于在 MySQL 中使用mod_authn_dbd 的教程,但我在使用 ODBC 的 SQL Server 中找不到任何教程。 It took me a while to figure it out, so I decided to write it up here.我花了一段时间才弄明白,所以我决定把它写在这里。 It's not a full blown tutorial but it should be enough to get you up and running.这不是一个完整的教程,但它应该足以让您启动和运行。

All commands must be run as root or using sudo.所有命令都必须以 root 身份或使用 sudo 运行。

Install Microsoft ODBC drivers for Linux为 Linux 安装 Microsoft ODBC 驱动程序

Instructions on Microsoft site Microsoft 网站上的说明

Example for Debian 9: Debian 9 示例:

apt update
apt install curl apt-transport-https

curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt update
ACCEPT_EULA=Y apt-get install msodbcsql17

Configure /etc/odbc.ini配置/etc/odbc.ini

Example content:示例内容:

[DBSERVER1]
Driver = ODBC Driver 17 for SQL Server
Server = 192.168.1.123

Install and enable mod_authn_dbd安装并启用 mod_authn_dbd

apt install libaprutil1-dbd-odbc
a2enmod dbd
a2enmod authn_dbd
a2enmod authn_socache

Configure Apache authentication配置 Apache 身份验证

Add this somewhere in your site config:在您的站点配置中的某处添加:

DBDriver odbc
DBDParams "DATASOURCE=DBSERVER1,USER=dbuser,PASSWORD=dbpass"

<Location "/test">
        AuthType Basic
        AuthName "Secured area"
        AuthBasicProvider socache dbd

        AuthnCacheProvideFor dbd
        AuthnCacheContext my-server

        Require valid-user

        AuthDBDUserPWQuery "SELECT USR_PASS FROM USERS WHERE USR_EMAIL=%s"
</Location>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM