This flutter package uses a jdbc driver to send a connection request to SQL Server. On the SQL Server side, it does SQL authentication using the username and password it received. Instead of using SQL Server auth, is it possible to pass over Windows credentials and have SQL Server authenticate using that? Below is the code used in this package to connect.
private suspend fun connectToDB(call: MethodCall, result: Result) {
try {
val ip: String = call.argument<String>("ip").toString()
val port: String = call.argument<String>("port").toString()
val Classes = "net.sourceforge.jtds.jdbc.Driver"
val database = call.argument<String>("databaseName").toString()
val username = call.argument<String>("username").toString()
val password = call.argument<String>("password").toString()
val timeout = call.argument<Int>("timeout")
val url = "jdbc:jtds:sqlserver://$ip:$port/$database"
Class.forName(Classes)
DriverManager.setLoginTimeout(timeout!!.toInt())
connection = DriverManager.getConnection(url, username, password)
result.success(true)
} catch (e: Throwable) {
result.error("ERROR", e.message.toString(), null)
} catch (e: ClassNotFoundException) {
result.error("ClassNotFoundException", e.message.toString(), null)
} catch (e: SQLException) {
result.error("SQLException", e.message.toString(), null)
} catch (e: Exception) {
result.error("Exception", e.message.toString(), null)
}
}