Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Problem accessing linked server


Problem accessing linked server

Author
Message
ankur.bhargava
ankur.bhargava
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 42
Hi All,

I am facing some problems while accessing linked server created with windows authentication. Here are the steps I performed:

1) Login with User1 on SQL management studio.
2) Create linked server from following queries:

EXEC sp_addlinkedserver @server='ANKUR02', @srvproduct='', @provider='SQLNCLI', @datasrc='ANKUR01',@provstr='Integrated Security=SSPI;';
exec sp_addlinkedsrvlogin 'ANKUR02', 'true'

3) Running the query Select * from ankur02.smshirts.dbo.results gives the error message
Msg 7416, Level 16, State 2, Line 1
Access to the remote server is denied because no login-mapping exists.

Can anyonle tell me what I am doing wrong here.

Thanks in advance for any assistance.
Ankur Bhargava
raj acharya
raj acharya
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 396
first try to do test connection through right click on linked server and test connection ... i think this problem come's because of wrong setting of connection

Raj Acharya
ankur.bhargava
ankur.bhargava
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 42
Hi Raj,

Thanks for your prompt reply. When i right click on linked server it gives me error that user must me belong to sysadmin.

Although when I login with windows authentication or with sa then I am able to run query using this linked server.

So I think, the problem is in when accessing linked server from non sa user eventhough we create the linked server throught that same non sa user.

Ankur Bhargava
Paresh Prajapati
Paresh Prajapati
Old Hand
Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)

Group: General Forum Members
Points: 327 Visits: 464
ankur.bhargava (1/9/2009)
Hi All,

I am facing some problems while accessing linked server created with windows authentication. Here are the steps I performed:

1) Login with User1 on SQL management studio.
2) Create linked server from following queries:

EXEC sp_addlinkedserver @server='ANKUR02', @srvproduct='', @provider='SQLNCLI', @datasrc='ANKUR01',@provstr='Integrated Security=SSPI;';
exec sp_addlinkedsrvlogin 'ANKUR02', 'true'

3) Running the query Select * from ankur02.smshirts.dbo.results gives the error message
Msg 7416, Level 16, State 2, Line 1
Access to the remote server is denied because no login-mapping exists.

Can anyonle tell me what I am doing wrong here.

Thanks in advance for any assistance.
Ankur Bhargava


Whenever u create link server with login id, it should be exist in both servers.
I think this is the ur problem why u not able to access and able to only with windows authnitcation..
pls try below qury to create link server:



USE master;
GO
EXEC sp_addlinkedserver 'p123', N'SQL Server'
GO

USE [master]
GO
EXEC master.dbo.sp_serveroption @server=N'p123', @optname=N'data access', @optvalue=N'true'
GO

USE [master]
GO
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'p123', @locallogin = NULL , @useself = N'False', @rmtuser = N'dba', @rmtpassword = N'dba'
GO


Note : "dba" should be exist in both servers.

_____________________________________________________________________________________________________________
Paresh Prajapati
Arrow +919924626601
http://paresh-sqldba.blogspot.com/
LinkedIn | Tweet Me | FaceBook | Brijj
ankur.bhargava
ankur.bhargava
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 42
Hi Paresh,

Thanks for the response and suggestions. On running the queries you suggested, linked server is created successfully but I am getting the below error while querying through it.
Query
Select * from [ANKUR01].SmShirts.dbo.History
Error
Msg 18456, Level 14, State 1, Line 1
Login failed for user 'dba'.

Here are the requirements what exactly I want.
1) User login into dot net application through USer1 which has only dbowner rights on the application database.
2) From an configuration form user will choose another database which needs to be queried in conjunction with application database. This new database can be remote/local and can be accessed through SQL/Windows authentication.
3) To access this new database I need to create an linked server.

Please suggest me what should I do in this case to create linked server. Keeping in mind that database can be local/remote and can be accessed through SQL/Windows authentication.

Thanks in advance.
Ankur Bhargava
raj acharya
raj acharya
SSC-Enthusiastic
SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)SSC-Enthusiastic (189 reputation)

Group: General Forum Members
Points: 189 Visits: 396
Hi,

try below query wherever you see servername put there your server name you have to create one user with admin rights on the server which you want to link with the source server and then put that server's username and password here and try,





/****** Object: LinkedServer [servername] Script Date: 01/12/2009 18:54:45 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'servername', @srvproduct=N'SQL Server'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'servername',@useself=N'False',@locallogin=NULL,@rmtuser=N'raj',@rmtpassword='########'

GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'use remote collation', @optvalue=N'true'

Raj Acharya
Ed Zann
Ed Zann
Mr or Mrs. 500
Mr or Mrs. 500 (505 reputation)Mr or Mrs. 500 (505 reputation)Mr or Mrs. 500 (505 reputation)Mr or Mrs. 500 (505 reputation)Mr or Mrs. 500 (505 reputation)Mr or Mrs. 500 (505 reputation)Mr or Mrs. 500 (505 reputation)Mr or Mrs. 500 (505 reputation)

Group: General Forum Members
Points: 505 Visits: 1391
I think you are experiencing the "double hop" issue with Windows Authentication (you can Google that for more details). Basically, Unless you have Kerberos enabled for these servers, you cannot pass the Windows credentials for User1 from one SQL Server over to your remote linked server.

I do not know much about Kerberos, other than it is required if you want to pass Windows Authenticated user credentials between servers.

Generally I will define a standard SQL Login on the remote server and use that login to set up my Linked Server. In other words I will be logged into the primary SQL server with my Windows login, but will log into the remote server with a static SQL login. Not the greatest solution if you need to audit the actual user accessing the remote server - but the only way to do this that I know about.



Paresh Prajapati
Paresh Prajapati
Old Hand
Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)Old Hand (327 reputation)

Group: General Forum Members
Points: 327 Visits: 464
raj acharya (1/12/2009)
Hi,

try below query wherever you see servername put there your server name you have to create one user with admin rights on the server which you want to link with the source server and then put that server's username and password here and try,





/****** Object: LinkedServer [servername] Script Date: 01/12/2009 18:54:45 ******/
EXEC master.dbo.sp_addlinkedserver @server = N'servername', @srvproduct=N'SQL Server'
/* For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'servername',@useself=N'False',@locallogin=NULL,@rmtuser=N'raj',@rmtpassword='########'

GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'INDIADEV', @optname=N'use remote collation', @optvalue=N'true'






Great

_____________________________________________________________________________________________________________
Paresh Prajapati
Arrow +919924626601
http://paresh-sqldba.blogspot.com/
LinkedIn | Tweet Me | FaceBook | Brijj
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search