RE: Use a Trusted Connection With OPENROWSET?

From: Mike Epprecht (SQL MVP) (mike_at_epprecht.net)
Date: 09/21/04


Date: Tue, 21 Sep 2004 01:25:03 -0700

Hi

The OPENROWSET is done in the context of the SQL Server account that is
running on the server. Most of the time it is the local machine account. Make
sure SQL Server is running under a doamin account and that that account has
rights on the destination server.

Regards
Mike

"John" wrote:

> Has anybody, anywhere figured out a way to use a trusted connection (Windows
> authentication) with OPENROWSET? The first two queries below used to work
> just fine because they use SQL authentication. The four queries after that
> are various sad, sad (and unworking) attempts I've made at using Windows
> authentication.
>
> We've begun cycling the sa password daily so the first two queries no longer
> work. There are ways to deal with that, so the problem I'm left with is
> merely an academic one. Can a trusted connection be used with OPENROWSET?
> If so, what would the query look like?
>
>
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB', 'myserver'; 'sa'; 'mypassword', 'SET FMTONLY OFF
> EXEC master..sp_who2') AS a
> WHERE a.BlkBy <> ' . '
> ORDER BY a.ProgramName
>
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB', 'myserver'; 'sa'; 'mypassword', 'SET FMTONLY OFF
> EXEC master..sp_who2') AS a
> WHERE a.BlkBy <> ' . '
> ORDER BY a.ProgramName
>
> ----------------------------------------------------------------------
>
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB', 'DRIVER={SQL Server}; SERVER=myserver;Trusted
> Connection=yes', 'SET FMTONLY OFF EXEC master..sp_who2') AS a
> WHERE a.BlkBy <> ' . '
> ORDER BY a.ProgramName
>
> SELECT a.*
> FROM OPENROWSET('Driver={SQL
> Server};Server=myserver;Database=master;Trusted_Connection=yes, ''''SET
> FMTONLY OFF EXEC master..sp_who2') AS a
> WHERE a.BlkBy <> ' . '
> ORDER BY a.ProgramName
>
> SELECT a.*
> FROM OPENROWSET('Provider=sqloledb;Data Source=myserver;Initial
> Catalog=pubs;Integrated Security=SSPI, ''''SET FMTONLY OFF EXEC
> master..sp_who2''') AS a
> WHERE a.BlkBy <> ' . '
> ORDER BY a.ProgramName
>
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB', 'myserver'; 'Integrated Security=SSPI ', 'SET
> FMTONLY OFF EXEC master..sp_who2') AS a
> WHERE a.BlkBy <> ' . '
> ORDER BY a.ProgramName
>
>
>



Relevant Pages

  • Re: update index in background not running.
    ... in order to allow an .net web program to access the SQL server you have to ... add IIS_WPG account to the database, ... > exec sp_defaultdb N'NT Authority\System', ...
    (microsoft.public.sqlserver.fulltext)
  • Re: The Microsoft Search service cannot be administered under the pres
    ... the BUILTIN\Administrator account as well as a member of the Sysadmin role? ... SQL Server Full-Text Search Does Not Populate Catalogs ... you or your server's sysadmin have removed the ... exec sp_defaultdb N'NT Authority\System', N'master' ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Full Text Indexing not Populating
    ... You're welcome, JayB, ... SQL Server Full-Text Search Does Not Populate Catalogs ... MSSQLServer Logon Account Through [NT4.0) Control Panel [or Win2K Component ... exec sp_defaultdb N'NT Authority\System', N'master' ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Cant Administer
    ... Can you verify that the MSSearch account is running under the local system ... Has anyone modified the SQL Server service account through the ... system administrators role. ... exec sp_defaultdb N'NT Authority\System', N'master' ...
    (microsoft.public.sqlserver.fulltext)
  • Re: error with OpenRowSet
    ... > it's not a problem with OPENROWSET. ... It sounds like the account used by ... out what permissions SQL Server has & how do I/we change them? ...
    (microsoft.public.sqlserver.programming)