![Docker SQL Server 从 IIS 远程登录用户 sa 失败](https://linux22.com/image/741813/Docker%20SQL%20Server%20%E4%BB%8E%20IIS%20%E8%BF%9C%E7%A8%8B%E7%99%BB%E5%BD%95%E7%94%A8%E6%88%B7%20sa%20%E5%A4%B1%E8%B4%A5.png)
当我尝试使用在 IIS dockerfile 中配置的 DSN 通过用户名和密码将 ASP Classic Web 应用程序(托管在 IIS 10 中)连接到 SQL Server 2014 时出现此错误:
Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'sa'.
我可以使用 SSMS 登录“sa”帐户,但不能使用相同的凭据从 ASP Classic Web 应用程序登录。
该环境配置在 2 个 Docker 容器中,分别是 2 个 dockerfile:
SQL Server Dockerfile
FROM microsoft/windowsservercore:1803
# Download Links:
ENV exe "https://go.microsoft.com/fwlink/?linkid=840945"
ENV box "https://go.microsoft.com/fwlink/?linkid=840944"
ENV SA_PASSWORD="Password~1234" \
attach_dbs="[]" \
ACCEPT_EULA="Y" \
SA_PASSWORD_path="C:\ProgramData\Docker\secrets\sa-password"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# make install files accessible
COPY start.ps1 /
WORKDIR /
RUN Invoke-WebRequest -Uri $env:box -OutFile SQL.box ; \
Invoke-WebRequest -Uri $env:exe -OutFile SQL.exe ; \
Start-Process -Wait -FilePath .\SQL.exe -ArgumentList /qs, /x:setup ; \
.\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\NETWORK SERVICE' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \
Remove-Item -Recurse -Force SQL.exe, SQL.box, setup
RUN stop-service MSSQLSERVER ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.MSSQLSERVER\mssqlserver\' -name LoginMode -value 2 ;
HEALTHCHECK CMD [ "sqlcmd", "-Q", "select 1" ]
CMD .\start -SA_PASSWORD $env:SA_PASSWORD -ACCEPT_EULA $env:ACCEPT_EULA -attach_dbs \"$env:attach_dbs\" -Verbose
IIS Dockerfile
FROM microsoft/iis
SHELL ["powershell", "-command"]
ENV USER_NAME="iisadmin"
ENV USER_PASSWORD="Password~1234"
RUN Install-WindowsFeature Web-ASP;
RUN Install-WindowsFeature Web-CGI;
RUN Install-WindowsFeature Web-ISAPI-Ext;
RUN Install-WindowsFeature Web-ISAPI-Filter;
RUN Install-WindowsFeature Web-Includes;
RUN Install-WindowsFeature Web-HTTP-Errors;
RUN Install-WindowsFeature Web-Common-HTTP;
RUN Install-WindowsFeature Web-Performance;
RUN Install-WindowsFeature WAS;
RUN Import-module IISAdministration;
# setup Remote IIS management
RUN Install-WindowsFeature Web-Mgmt-Service; \
New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force; \
Set-Service -Name wmsvc -StartupType automatic;
# Add user for Remote IIS Manager Login
RUN net user $env:USER_NAME $env:USER_PASSWORD /ADD; \
net localgroup administrators $env:USER_NAME /add;
# Temporal folder for installations files
RUN md c:/msi;
RUN Invoke-WebRequest 'http://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi' -OutFile c:/msi/urlrewrite2.msi;
RUN Start-Process 'c:/msi/urlrewrite2.msi' '/qn' -PassThru | Wait-Process;
RUN Invoke-WebRequest 'https://download.microsoft.com/download/1/E/7/1E7B1181-3974-4B29-9A47-CC857B271AA2/English/X64/msodbcsql.msi' -OutFile c:/msi/msodbcsql.msi;
RUN ["cmd", "/S", "/C", "c:\\windows\\syswow64\\msiexec", "/i", "c:\\msi\\msodbcsql.msi", "IACCEPTMSODBCSQLLICENSETERMS=YES", "ADDLOCAL=ALL", "/qn"];
EXPOSE 8000
RUN Remove-Website -Name 'Default Web Site';
RUN md c:\mywebsite;
RUN New-IISSite -Name "mywebsite" -PhysicalPath 'c:\mywebsite' ` -BindingInformation "*:8000:";
RUN & c:\windows\system32\inetsrv\appcmd.exe unlock config /section:system.webServer/asp
RUN & c:\windows\system32\inetsrv\appcmd.exe unlock config /section:system.webServer/handlers
RUN & c:\windows\system32\inetsrv\appcmd.exe unlock config /section:system.webServer/modules
RUN c:\windows\system32\inetsrv\appcmd.exe set config "mywebsite" -section:system.webServer/asp /scriptErrorSentToBrowser:"True"
RUN Add-OdbcDsn -Name "mywebsite" -DriverName "\"ODBC Driver 13 For SQL Server\"" -DsnType "System" -SetPropertyValue @("\"Server=172.20.0.4\"", "\"Trusted_Connection=No\"");
WORKDIR c:\\mywebsite