sql-server - Spring Boot:通过 Active Directory 用户连接到 MSSQL
问题描述
我喜欢将 Spring Boot 应用程序部署到 K8s 集群并连接到 MSSQL 数据库。驱动定义为:
spring.datasource.driverClassName=net.sourceforge.jtds.jdbc.Driver
目前,我通过数据库本身实现的用户进行连接。这是连接字符串:
datasourceUrl: jdbc:jtds:sqlserver://server-host/db-name;instance=MSSQL
现在,我想使用 Actice Directory 用户。因此,我更新了凭据。然后,无法再建立连接。一些研究表明,向连接字符串添加domain=domain-name
或integratedSecurity=true
应该启用连接。不幸的是,两者都不起作用。
使用domain=domain-name
导致:
登录来自不受信任的域,不能用于 Windows 身份验证
使用integratedSecurity=true
导致:
ConfigServletWebServerApplicationContext:上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:在类路径资源 [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$ 中定义名称为“jdbcConverter”的 bean 创建错误SpringBootJdbcConfiguration.class]:通过方法'jdbcConverter'参数4表示的不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class] 中定义名称为“jdbcDialect”的 bean 创建时出错:通过工厂进行 Bean 实例化方法失败;嵌套异常是 org.springframework.beans。BeanInstantiationException:无法实例化[org.springframework.data.relational.core.dialect.Dialect]:工厂方法'jdbcDialect'抛出异常;嵌套异常是 org.springframework.jdbc.CannotGetJdbcConnectionException: 获取 JDBC 连接失败;嵌套异常是 java.sql.SQLException: Login failed for user 'ad-username'
关于如何通过 Active Directory 用户建立与 MSSQL 数据库的连接的任何想法?
解决方案
谢谢丹·古兹曼的评论。
还有另一种方法,您可以通过将 Active Directory 用户组添加为登录名来通过 Active Directory 用户建立与 MSSQL 数据库的连接。它描述了如何使用 SQL Server Management Studio 或 Transact-SQL 在 SQL Server 或 SQL 数据库中创建登录。登录名是连接到 SQL Server 实例的人员或进程的身份。
请参考这里讨论过的这个 MS Q&A:https ://docs.microsoft.com/en-us/answers/questions/131424/how-to-add-active-directory-user-group-as-login-在.html
推荐阅读
- javascript - Reactjs无法打印ID
- reactjs - 如何让 reactJS 呈现状态变量
- eclipse - Eclipse 在运行或调试期间未使用 gradle 依赖项 jar
- while-loop - 在while循环之外定义的变量没有在里面定义?
- python - 熊猫时间序列,过滤倒数第二个工作日
- javascript - 反应原生如何将两个数组与函数合并
- python - wx.App 在一个程序中运行,而不在另一个程序中运行
- mysql - 如何连接到远程服务器上的数据库
- php - 将proxy_fcgi php错误输出重定向到浏览器页面(apache2,fpm)
- python - 如何展开基于键值“对”的python列表字典?