Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Problem accessing linked server Expand / Collapse
Author
Message
Posted Friday, January 9, 2009 1:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 26, 2009 5:00 AM
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
Post #633165
Posted Friday, January 9, 2009 2:36 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, December 12, 2013 1:15 AM
Points: 187, Visits: 376
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
Post #633187
Posted Friday, January 9, 2009 2:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 26, 2009 5:00 AM
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
Post #633196
Posted Friday, January 9, 2009 10:09 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, June 18, 2013 7:41 AM
Points: 323, 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
+919924626601
http://paresh-sqldba.blogspot.com/
LinkedIn | Tweet Me | FaceBook | Brijj
Post #634088
Posted Monday, January 12, 2009 12:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 26, 2009 5:00 AM
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
Post #634498
Posted Monday, January 12, 2009 6:28 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, December 12, 2013 1:15 AM
Points: 187, Visits: 376
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
Post #634623
Posted Tuesday, January 13, 2009 1:17 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 6:50 AM
Points: 487, Visits: 1,229
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.



Post #635789
Posted Thursday, January 15, 2009 11:11 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, June 18, 2013 7:41 AM
Points: 323, 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
+919924626601
http://paresh-sqldba.blogspot.com/
LinkedIn | Tweet Me | FaceBook | Brijj
Post #637746
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse