Problem accessing linked server

  • 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

  • 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

  • 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

  • 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/[/url]
    LinkedIn | Tweet Me | FaceBook | Brijj

  • 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

  • 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

  • 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.

  • 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/[/url]
    LinkedIn | Tweet Me | FaceBook | Brijj

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply