tags:

views:

276

answers:

5

I want to create a linked server in one sql server to another using the sp_addlinkedserver procedure. When i access the remote server I would like it to logon as me (i.e. using my windows account). How do I do this?

A: 

Use SQL Management Studio to see the properties for the linked server. There you will find your logon information

TT
+1  A: 

You can do this with the sp_addlinkedsrvlogin procedure:

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'<your linked server name>',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL

This assumes you log in to the server on which the link was created using Windows authentication.

Ed Harper
Thanks Ed. I tried this and now I get the message:Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
cindi
It sounds like you're using SQL Server authentication when you connect to SQL server. If so, your SQL Server session does not know what your Windows identity is.You can set the linked server up to explicitly use your Windows identity, but other people who log on to SQL will be able to access the...
Ed Harper
...linked server using your identity. For this reason, it's not normally recommended.
Ed Harper
+1  A: 

This can be maddening to set up. Check this related question:

http://stackoverflow.com/questions/33153/sql-server-to-sql-server-linked-server-setup

With Sql Server 2005 on a 2K3 domain, the most secure way to set up a linked server, unfortunately, is probably to use an old fashioned Sql Login. You have to make a lot of what I consider risky changes to your domain security settings to get it to work with a domain account.

Eric Z Beard
+1  A: 

Following on from Ed Harper above:

You need to set "Security Account Delegation" for the SQL service account to enable it to pass through your login token.

Edit:

This is not a SQL problem. Delegation/pass through authentication is a Windows/AD feature.

It's also used to enable an intranet web site to use the end user windows login to authenticate onto the SQL box where (of course) the web server is a separate box. In this scenario, you configure the web server for delegation.

In the OP's scenario, we are enabling the 1st SQL box to delegate credentials onto the 2nd box.

Edit2:

The other thread explains this too.

Finally, nothing to do with SQL logins.

gbn
A: 

Thanks for the answers. Windows/AD are not my area, so I did as Eric suggested and settled for an SQL Login.

cindi