本文介绍了如何配置JDBC连接使用不同的AD用户比目前的用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MS SQL Server 2008 R2的数据库中的DBNAME的托管服务器上的主机名的是由域的ABCActive Directory用户访问,让我们叫他的DBUSERABC \ dbuser的的。

The MS SQL Server 2008 R2 database "dbname" hosted on server "HOSTNAME" is accessible by an Active Directory user from domain "ABC", let's call him "dbuser" or "ABC\dbuser".

我们正在运行我们的应用程序作为AD用户的ABC \ APPUSER的。 APPUSERDBUSER的是在不同的广告组。

We are running our application as AD user "ABC\appuser". "appuser" and "dbuser" are in different AD groups.

在通过下运行的服务运行的ABC \ APPUSER的,连接使用用户的ABC \ APPUSER的连接到数据库:

When run by the service running under "ABC\appuser", the connection uses user "ABC\appuser" to connect to the database:

DriverManager.getConnection(
  "jdbc:sqlserver://HOSTNAME:1433;databaseName=dbname;integratedSecurity=true", 
  "", ""
);

使用相同的连接字符串和供应的ABC \ dbuser的的和密码的DBPASS的,连接忽略这些值,而是再次尝试使用AD信息服务正在运行作为,ABC \ APPUSER的:

Using the same connection string and supplying the "ABC\dbuser" and password "dbpass", the connection ignores those values and instead again attempts to use the AD info the service is running as, "ABC\appuser":

DriverManager.getConnection(
  "jdbc:sqlserver://HOSTNAME:1433;databaseName=dbname;integratedSecurity=true", 
  "ABC\\dbuser", "dbpass"
);

删除标记 integratedSecurity = TRUE ,连接对待的ABC \ dbuser的的作为SQL帐户而不是AD帐户,抛出一个 SQLServerException

Removing flag integratedSecurity=true, the connection treats "ABC\dbuser" as a SQL account instead of an AD account, throwing a SQLServerException:

DriverManager.getConnection(
  "jdbc:sqlserver://HOSTNAME:1433;databaseName=dbname", 
  "ABC\\dbuser", "dbpass"
);

抛出

com.microsoft.sqlserver.jdbc.SQLServerException: 
  Login failed for user 'ABC\dbuser'.

到目前为止,我要承担,这不是可能的,而且我将拥有数据库团队要么提供的ABC \ APPUSER的AD访问数据库,或者把ABC \ APPUSER的成AD组,并给了AD组访问数据库。我不提供访问配置数据库;我只能提供咨询/方向。

So far, I'm about to assume that it's not possible and that I'm going to have the database team either provide "ABC\appuser" AD access to the database, or put "ABC\appuser" into an AD group and give that AD group access to the database. I am not provided access to configure the database; I can only provide advice/direction.

推荐答案

连接字符串具有用户名和密码参数。

The connection string has parameters for user and password.

用户= YYY;密码= XXX

也许尝试通过连接字符串设置凭据,并留下用户名/密码参数作为您的ABC \ dbuser的连接空字符串。我不知道这是否会工作,但它发送凭据的另一种方法。

Maybe try setting the credentials via the connection string and leaving the user/password parameters as empty string for your ABC\dbuser connections. I'm not sure if this will work but it's an alternate way to send credentials.

这篇关于如何配置JDBC连接使用不同的AD用户比目前的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 04:01