diff --git a/docs/guide/jsonrpc_protocol.md b/docs/guide/jsonrpc_protocol.md
index 9820cb51..b78d2eaa 100644
--- a/docs/guide/jsonrpc_protocol.md
+++ b/docs/guide/jsonrpc_protocol.md
@@ -533,9 +533,14 @@ Get a connection string for the provided connection.
public string OwnerUri { get; set; }
///
- /// Indicates whether the password should be return in the connection string
+ /// Indicates whether the password should be return in the connection string. Default is false.
///
public bool IncludePassword { get; set; }
+
+ ///
+ /// Indicates whether the application name should be return in the connection string. Default is true.
+ ///
+ public bool? IncludeApplicationName { get; set;}
}
```
#### Response
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs
index 6c30cda9..f30fc5a6 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs
@@ -1327,9 +1327,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{
connStringBuilder.Password = ConnectionService.PasswordPlaceholder;
}
-
- connStringBuilder.ApplicationName = "sqlops-connection-string";
-
+ // default connection string application name to always be included unless set to false
+ if (!connStringParams.IncludeApplicationName.HasValue || connStringParams.IncludeApplicationName.Value == true)
+ {
+ connStringBuilder.ApplicationName = "sqlops-connection-string";
+ }
connectionString = connStringBuilder.ConnectionString;
}
catch (Exception e)
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/GetConnectionStringParams.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/GetConnectionStringParams.cs
index 408ec136..8d151405 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/GetConnectionStringParams.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/GetConnectionStringParams.cs
@@ -17,7 +17,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
///
/// Indicates whether the password should be return in the connection string
+ /// default is set to false
///
public bool IncludePassword { get; set; }
+
+ ///
+ /// Indicates whether the application name should be return in the connection string
+ /// default is set to true
+ ///
+ public bool? IncludeApplicationName { get; set;}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs
index 82677d09..a8f3d568 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/Connection/ConnectionServiceTests.cs
@@ -124,7 +124,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
var requestParams = new GetConnectionStringParams()
{
OwnerUri = result.ConnectionInfo.OwnerUri,
- IncludePassword = false
+ IncludePassword = false,
+ IncludeApplicationName = true
};
await service.HandleGetConnectionStringRequest(requestParams, requestContext.Object);
@@ -139,5 +140,31 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
await service.HandleGetConnectionStringRequest(requestParams, requestContext.Object);
requestContext.VerifyAll();
}
+
+ ///
+ /// Test HandleGetConnectionStringRequest
+ /// When IncludeApplicationName is set to false the connection string should not contain the application name
+ ///
+ [Test]
+ public async Task GetCurrentConnectionStringTestwithoutApplicationName()
+ {
+ // If we make a connection to a live database
+ ConnectionService service = ConnectionService.Instance;
+ var result = LiveConnectionHelper.InitLiveConnectionInfo();
+ var resultApplicationName = result.ConnectionInfo.ConnectionDetails.ApplicationName;
+ var requestContext = new Mock>();
+
+ requestContext.Setup(x => x.SendResult(It.Is((connectionString) => !connectionString.Contains("Application Name="+ resultApplicationName))))
+ .Returns(Task.FromResult(new object()));
+ var requestParams = new GetConnectionStringParams()
+ {
+ OwnerUri = result.ConnectionInfo.OwnerUri,
+ IncludePassword = false,
+ IncludeApplicationName = false
+ };
+
+ await service.HandleGetConnectionStringRequest(requestParams, requestContext.Object);
+ requestContext.VerifyAll();
+ }
}
}