为什么 SQL 服务器使用不同的用户来创建会话?
Why is SQL Server using a different user to create the session?
我正在尝试从 .NET Core Web 应用程序连接到 SQL 服务器数据库,
这是我正在使用的连接字符串:
Server =.; Database = DBNAME; User Id = tb; Password = pass; Trusted_Connection = True; MultipleActiveResultSets = True;
.
之前的设置产生异常:
An error occurred using the connection to database 'DBNAME' on server '.'.
System.Data.SqlClient.SqlException (0x80131904): Error opening session for the user 'MyDomain\ServerMachineName$'.
我认为它正在尝试使用另一个域帐户进行连接,我什至没有在安全选项卡下的数据库用户列表中看到该帐户,也没有在服务器实例的用户中看到它。
在启动文件中,相关配置为:
services.AddDbContext<MyDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MyConnectionString")));
我尝试将具有所需权限的不同用户添加到 SQL 服务器实例和特定数据库,但其中 none 有效。
问题:
为什么系统完全忽略了我指定的连接字符串?
有解决办法吗?
Trusted_Connection = True;
的意思是忽略传入的用户 ID 和密码,而是使用用户 运行 程序的 windows 凭据。由于您的程序可能 运行 作为一项服务 "user" 它按原样运行 MyDomain\ServerMachineName$
。
将可信连接设置为 false
将使用连接字符串中提供的用户 ID 和密码。
我正在尝试从 .NET Core Web 应用程序连接到 SQL 服务器数据库, 这是我正在使用的连接字符串:
Server =.; Database = DBNAME; User Id = tb; Password = pass; Trusted_Connection = True; MultipleActiveResultSets = True;
.
之前的设置产生异常:
An error occurred using the connection to database 'DBNAME' on server '.'. System.Data.SqlClient.SqlException (0x80131904): Error opening session for the user 'MyDomain\ServerMachineName$'.
我认为它正在尝试使用另一个域帐户进行连接,我什至没有在安全选项卡下的数据库用户列表中看到该帐户,也没有在服务器实例的用户中看到它。
在启动文件中,相关配置为:
services.AddDbContext<MyDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MyConnectionString")));
我尝试将具有所需权限的不同用户添加到 SQL 服务器实例和特定数据库,但其中 none 有效。
问题:
为什么系统完全忽略了我指定的连接字符串?
有解决办法吗?
Trusted_Connection = True;
的意思是忽略传入的用户 ID 和密码,而是使用用户 运行 程序的 windows 凭据。由于您的程序可能 运行 作为一项服务 "user" 它按原样运行 MyDomain\ServerMachineName$
。
将可信连接设置为 false
将使用连接字符串中提供的用户 ID 和密码。