Question

I'm able to execute a stored procedure which queries a Linked Server directly, but when I call the same sproc though ASP.NET then I get the following error:

Access to the remote server is denied because no login-mapping exists.

When I execute it through SSMS, I am connected through my Windows domain account.

The site is ASP.NET with Forms Authentication on IIS 7 and SQL 2008 on my local machine.

The Linked Server is set up to "Be made using this security context" for all logins.

Was it helpful?

Solution

The login that you connect with to your initial database does not have access to the linked database. Why don't you use the account that the application impersonates to connect to the database in Management Studio, and diagnose the issue that way? If you know the login, just create it in the linked database as well with the required permissions.

If creating a new login on the linked server is not an option, create a mapping. If you read the fine print on the wizard, it says "for logins not defined in the list above, connections will be made" using the current security context. Which means that if you don't define a mapping, it will use the current credentials for the link.

OTHER TIPS

There are two login/password pairs required. One is for the SQL server that has the linked server on it. The 2nd is for the 'thing' the linked server is connecting to. E.g. There is an ODBC connection on the same machine SQL server is on. This ODBC connection connects to an ORACLE db. During the ODBC setup a user name and a password were required: UN "XYZ", PWD "123". When creating the linked server to this ODBC connection its necessary to add the user name "XYZ" and password "123". This is done on the security page of the linked server properties. Click "ADD" and in the 'Local Login' box enter the SQL server user name that the app uses to connect to SQL server. In the 'Remote User' box enter 'XYZ' and in the 'Remote Password' enter '123'. Finally select 'Be made using the login's current security context'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top