简体   繁体   English

远程连接到SQL Server-可信连接,Windows凭据

[英]Remote connect to SQL server - trusted connection, windows credentials

Sorry for the confusing name, I did not know of better one. 对不起,这个名字令人困惑,我不知道有更好的名字。 There is a network with SQL 2005 server. 有一个带有SQL 2005服务器的网络。 I am provided with the windows account information to this computer so I can use remote desktop or map its drives. 我已将Windows帐户信息提供给此计算机,因此可以使用远程桌面或映射其驱动器。 The SQL uses trusted connection. SQL使用受信任的连接。 I am thinking whether I can connect remotely only to the SQL server? 我在考虑是否只能远程连接到SQL Server? Thanks 谢谢

This is based on my experience with SQL Server, but may not be entirely complete in scope. 这是基于我对SQL Server的经验,但是范围可能并不完整。

SQL Server Manager will let you connect to the server instance with windows credentials, but to access the database tables you will need to create a login within SQL Server. SQL Server Manager将允许您使用Windows凭据连接到服务器实例,但是要访问数据库表,您将需要在SQL Server中创建登录名 Using SQL Server Manager, you can do this under the Security folder of the hierarchy of objects in the left column. 使用SQL Server Manager,可以在左列的对象层次结构的“安全性”文件夹下执行此操作。

Next you will need to create a database (if one doesn't already exist that you are interested in using) and in that database's Security folder, create a user that corresponds to the login. 接下来,您将需要创建一个数据库(如果尚不存在您感兴趣的数据库),然后在该数据库的“安全性”文件夹中,创建一个与登录名相对应的用户 When doing this you will also need to assign the permissions of the user (select, insert, delete, etc.). 这样做时,您还需要分配用户的权限(选择,插入,删除等)。

Once that is complete, you can access the server anywhere on the network with the appropriate credentials, but you will need to make sure that there are no blocked ports, etc. from a network perspective. 一旦完成,就可以使用适当的凭据访问网络上任何位置的服务器,但是从网络角度来看,您需要确保没有阻塞的端口等。

In C# the statement to create a new connection looks like this: 在C#中,创建新连接的语句如下所示:

SqlConnection conn = new SqlConnection("user id = username; " +
    "password = secret; " +
    "server = servername\sqlexpress; " +
    "database = databasename; " +
    "connection timeout = 30");

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可信的SQL Server连接 - trusted SQL Server connection C#Windows应用程序:使用Windows身份验证连接到远程SQL Server 2008的连接字符串 - C# Windows application: connection string to connect to remote sql server 2008 using windows authentication Windows身份模拟不持久到Sql Trusted Connection中 - Windows Identity Impersonation not persisting into Sql Trusted Connection 如何使用客户端Windows凭据连接到Web中的SQL Server数据库 - How to connect to SQL Server database in web using client windows credentials 无法使用来自 UWP-App 的可信连接连接到 SQL Server - Can't connect to SQL Server using Trusted Connection from UWP-App Windows FTP连接显示无法连接到远程服务器 - Windows FTP Connection says Unable to connect to the remote server 可以连接到远程SQL Server,但是连接字符串测试失败 - Can connect to the remote SQL server, but connection string test fails 无法通过Windows身份验证使用连接字符串连接到SQL Server - Unable to connect to SQL Server using a connection string with Windows authentication 连接字符串,用于使用其他Windows帐户连接SQL Server - Connection String to connect a SQL Server using another windows account 提供SQL Server信任连接的用户名和密码 - Provide user name and password for SQL Server trusted connection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM