There are many tutorial for using mod_authn_dbd with MySQL but I could not find any with SQL Server using ODBC. 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.
Install Microsoft ODBC drivers for Linux
Instructions on Microsoft site
Example for 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
Example content:
[DBSERVER1]
Driver = ODBC Driver 17 for SQL Server
Server = 192.168.1.123
Install and enable mod_authn_dbd
apt install libaprutil1-dbd-odbc
a2enmod dbd
a2enmod authn_dbd
a2enmod authn_socache
Configure Apache authentication
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.