Skip to content

Commit 97861c7

Browse files
committed
#104 support trusted_connection param for MSSQL
1 parent 5a0009c commit 97861c7

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.github/workflows/dub.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ jobs:
136136
137137
mssql:
138138
#image: microsoft/mssql-server-linux:2017-latest
139-
image: mcr.microsoft.com/mssql/server:2019-latest
139+
#image: mcr.microsoft.com/mssql/server:2019-latest
140+
image: mcr.microsoft.com/mssql/server:2022-latest
140141
ports: [1433]
141142
env:
142143
MSSQL_PID: Developer
@@ -185,4 +186,4 @@ jobs:
185186
PORT: ${{ job.services.mssql.ports[1433] }}
186187
run: |
187188
sudo ACCEPT_EULA=Y apt-get install msodbcsql17 -y
188-
./ddbctest --connection=odbc://127.0.0.1:$PORT --database=dbo --user=SA --password=MSbbk4k77JKH88g54 --driver="ODBC Driver 17 for SQL Server"
189+
./ddbctest --connection=odbc://127.0.0.1:$PORT --database=dbo --user=SA --password=MSbbk4k77JKH88g54 --driver="ODBC Driver 17 for SQL Server" --trusted_connection=yes

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ services:
2020
- POSTGRES_USER=postgres
2121
- POSTGRES_PASSWORD=
2222
mssql:
23-
image: microsoft/mssql-server-linux:2017-latest
23+
image: mcr.microsoft.com/mssql/server:2022-latest
24+
#image: mcr.microsoft.com/mssql/server:2019-latest
25+
#image: mcr.microsoft.com/mssql/server:2017-latest
2426
restart: always
2527
ports: ['1433:1433']
2628
environment:

example/source/testddbc.d

+4-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct ConnectionParams
8282
string host;
8383
ushort port;
8484
string database;
85+
string trusted_connection; // for MS-SQL can be setto 'yes'
8586
}
8687
int main(string[] args)
8788
{
@@ -97,7 +98,8 @@ int main(string[] args)
9798
try
9899
{
99100
getopt(args, "user",&par.user, "password",&par.password, "ssl",&par.ssl,
100-
"connection",&URI, "database",&par.database, "driver",&par.odbcdriver);
101+
"connection",&URI, "database",&par.database, "driver",&par.odbcdriver,
102+
"trusted_connection",&par.trusted_connection);
101103
}
102104
catch (GetOptException)
103105
{
@@ -200,6 +202,7 @@ int main(string[] args)
200202
// ./ddbctest --connection=ddbc:odbc://localhost --user=SA --password=bbk4k77JKH88g54 --driver=FreeTDS
201203
params = ODBCDriver.setUserAndPassword(par.user, par.password);
202204
params["driver"] = par.odbcdriver;
205+
params["trusted_connection"] = par.trusted_connection;
203206
url = ODBCDriver.generateUrl(par.host, par.port, params);
204207
}
205208
}

source/ddbc/drivers/odbcddbc.d

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ version (USE_ODBC)
420420
addToConnectionString("username", "Uid");
421421
addToConnectionString("password", "Pwd");
422422
addToConnectionString("database", "Database");
423+
addToConnectionString("trusted_connection", "TrustServerCertificate");
423424
string connectionString = connectionProps.join(';');
424425

425426
sharedLog.info(connectionString);

0 commit comments

Comments
 (0)