茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1671308 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
HoneyMoon_Day2_00144.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

DB研討會 : [轉貼]SQL 使用 OPENROWSET 出現訊息 SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]SQL 使用 OPENROWSET 出現訊息 SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取

SQL 使用 OPENROWSET 出現訊息 SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取

當TSQL使用 OPENROWSET 會返回以下的錯誤訊息時的權限開放方式。

訊息:

訊息 15281,層級 16,狀態 1,程序 ,行 1
SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取,因為此元件已經由此伺服器的安全性組態關閉。系統管理員可以使用 sp_configure 來啟用 'Ad Hoc Distributed Queries' 的使用。如需有關啟用 'Ad Hoc Distributed Queries' 的詳細資訊,請參閱《SQL Server 線上叢書》中的<介面區組態>(Surface Area Configuration)。


Msg 15281, Level 16, State 1, Procedure , Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.

處理:

開放 'd Hoc Distributed Queries 的使用權限,開啟資料庫 - Facet


image

image

如果你習慣使用指令,則可以使用以下的語法,而開啟的服務對應表,則可以查詢這篇線上說明
組態選項表

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'ad hoc distributed queries', 1;
GO
RECONFIGURE;
GO

透過開啟此Facet的全縣,則可啟動 OPENROWSET 功能,能 XPCmdShellEnable 等相關設定,如上圖所顯示,
也是可透過 Facet 介面 或 語法方式開啟。

參考資料:

了解介面區組態
在新安裝 SQL Server 的預設組態中,許多功能都不會啟用。為了盡量減少可能會遭受惡意使用者攻擊的功能數目,SQL Server 會選擇性地單獨安裝和啟動主要服務與功能。系統管理員可在安裝期間變更這些預設值,也可以選擇性地啟用或停用 SQL Server 之執行中執行個體的功能。此外,從其他電腦連接時 ...

http://technet.microsoft.com/zh-tw/library/ms161956.aspx

SQL Server 介面區組態
介面區域縮小是一種停止或停用未使用元件的安全性措施。介面區域縮小可透過提供較少的系統潛在攻擊途徑,以協助增進安全性。
http://technet.microsoft.com/zh-tw/library/ms173748(SQL.90).aspx

當 OLE DB 資料來源不會被經常參考,因而不保證可設定連結伺服器時,您就可以使用特定名稱來做為資料表參考。在 SQL Server 中,您可以使用 OPENROWSET 與 OPENDATASOURCE 函數來提供特定名稱。

http://technet.microsoft.com/zh-tw/library/ms187873(SQL.100).aspx


您也可以使用 sp_configure 預存程序來設定 Database Engine 選項。如需詳細資訊,請參閱<設定伺服器組態選項>。

http://technet.microsoft.com/zh-tw/library/ms189631.aspx

 


原文出處:SQL 使用 OPENROWSET 出現訊息 SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取 | 阿達林 - 點部落
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]SQL Server 2008 介面區組態(Surface Area Configuration,SAC):啟用 Ad Hoc Distributed Queries。訊息 15281,SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取

SQL Server 2008 介面區組態(Surface Area Configuration,SAC):啟用 Ad Hoc Distributed Queries。訊息 15281,SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取,因為此元件已經由此伺服器的安全性組態關閉。

在 SQL Server 2008 版本上,若要執行 OPENROWSET 或是 OPENDATASOURCE 時,遭遇以下的錯誤訊息,並請參考下圖所示:
訊息 15281,層級 16,狀態 1,行 1
SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取,因為此元件已經由此伺服器的安全性組態關閉。
系統管理員可以使用 sp_configure 來啟用 'Ad Hoc Distributed Queries' 的使用。
如需有關啟用 'Ad Hoc Distributed Queries' 的詳細資訊,請參閱《SQL Server 線上叢書》中的<介面區組態>(Surface Area Configuration)。


在「介面區組態」部分,預設是將設定 「AdHocRemoteQueriesEnabled」功能給「停用」的。
根據預設,SQL Server 不允許使用 OPENROWSET 和 OPENDATASOURCE 進行特定分散式查詢。
當啟用選項時,SQL Server 就會允許特定存取。當此選項未設定或設定為 0 時,SQL Server 就不允許特定存取。


若要啟用「Ad Hoc Distributed Queries」這項功能,請參考以下的方式:
  • 使用 SSMS 管理工具。

  • 使用T-SQL:sp_configure。

(一)使用 SSMS 管理工具
使用 SQL Server Management Studio 中的「Facet」來設定啟用和停用 SQL Server 功能。

步驟01. 使用 SQL Server Management Studio,連接到目標的 SQL Server。
步驟02. 在 [物件總管] 中,點選目標伺服器,滑鼠右鍵,選擇「Facet」。請參考下圖所示:


步驟03. 在「檢視 Facet」視窗,在右邊的「Facet」區域,選擇「介面區組態」。
步驟04. 在右下角的「Facet屬性」區域,選擇所需要啟用或是停用的功能。請參考下圖所示:


步驟05. 點選「確定」,完成設定後,就可以直接使用,無需重新啟動 SQL Server。



(二)使用T-SQL

--01 查詢是否已經啟用 Ad Hoc Distributed Queries
SELECT name N'組態選項的名稱', value N'針對這個選項所設定的值', value_in_use N'這個選項目前有效的執行值',
description N'組態選項的描述'
FROM sys.configurations
WHERE name='Ad Hoc Distributed Queries'
--02 設定啟用 Ad Hoc Distributed Queries
USE master;
GO
EXEC sp_configure 'show advanced option', '1';
GO
RECONFIGURE
GO
--
EXEC sp_configure 'Ad Hoc Distributed Queries', '1'
RECONFIGURE WITH OVERRIDE
GO
/* 顯示的訊息
組態選項 'show advanced options' 從 1 變更為 1。請執行 RECONFIGURE 陳述式來安裝。
組態選項 'Ad Hoc Distributed Queries' 從 0 變更為 1。請執行 RECONFIGURE 陳述式來安裝。
*/
--03 再度查詢是否已經啟用 Ad Hoc Distributed Queries
SELECT name N'組態選項的名稱', value N'針對這個選項所設定的值', value_in_use N'這個選項目前有效的執行值',
description N'組態選項的描述'
FROM sys.configurations
WHERE name='Ad Hoc Distributed Queries'



參考資料:
SQL Server 2008 介面區組態(Surface Area Configuration,SAC):啟用 xp_cmdshell
http://sharedderrick.blogspot.com/2009/04/sql-server-2008-surface-area.html

SQL Server 2005 Surface Area Configuration(SAC,介面區組態)
http://sharedderrick.blogspot.com/2009/05/clr-sql-server-2005.html

原文出處:德瑞克:SQL Server 學習筆記: SQL Server 2008 介面區組態(Surface Area Configuration,SAC):啟用 Ad Hoc Distributed Queries。訊息 15281,SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取,因為此元件已經由此伺服器的安全性組態關閉。
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]特定分散式查詢伺服器組態選項

特定分散式查詢伺服器組態選項 ad hoc distributed queries Server Configuration Option

根據預設, [SQL Server] SQL Server 不允許使用 OPENROWSET 和 OPENDATASOURCE 進行特定分散式查詢。 By default, [SQL Server] SQL Server does not allow ad hoc distributed queries using OPENROWSET and OPENDATASOURCE. 當此選項設定為 1 時, [SQL Server] SQL Server 就會允許特定存取。
When this option is set to 1, [SQL Server] SQL Server allows ad hoc access.
當此選項未設定或設定為 0 時, [SQL Server] SQL Server 就不允許特定存取。 When this option is not set or is set to 0, [SQL Server] SQL Server does not allow ad hoc access.

特定分散式查詢會使用 OPENROWSET 和 OPENDATASOURCE 函數,連接到使用 OLE DB 的遠端資料來源。 Ad hoc distributed queries use the OPENROWSET and OPENDATASOURCE functions to connect to remote data sources that use OLE DB. OPENROWSET 與 OPENDATASOURCE 只能用來參考不常存取的 OLE DB 資料來源。
OPENROWSET and OPENDATASOURCE should be used only to reference OLE DB data sources that are accessed infrequently.
對於經常存取的資料來源,請定義連結伺服器。 For any data sources that will be accessed more than several times, define a linked server.

重要

啟用特定名稱,表示 [SQL Server] SQL Server 的任何驗證登入都可以存取該提供者。 Enabling the use of ad hoc names means that any authenticated login to [SQL Server] SQL Server can access the provider. [SQL Server] SQL Server 對於任何可安全由本機登入存取的提供者,系統管理員應該為他啟用此功能。
administrators should enable this feature for providers that are safe to be accessed by any local login.

Remarks Remarks

嘗試進行特定連接但是未啟用 特定分散式查詢 會產生錯誤:訊息 7415、層級 16、狀態 1、行 1 Attempting to make an ad hoc connection with Ad Hoc Distributed Queries not enabled results in error: Msg 7415, Level 16, State 1, Line 1

特定存取至 OLE DB 提供者 'Microsoft.ACE.OLEDB.12.0' 已經遭到拒絕。 Ad hoc access to OLE DB provider 'Microsoft.ACE.OLEDB.12.0' has been denied. 您必須透過連結伺服器來存取此提供者。 You must access this provider through a linked server.


範例 Examples

下列範例會啟用特定分散式查詢,然後使用 Seattle1 函數來查詢名為 OPENROWSET 的伺服器。 The following example enables ad hoc distributed queries and then queries a server named Seattle1 using the OPENROWSET function.


sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
SELECT a.*
FROM OPENROWSET('SQLNCLI', 'Server=Seattle1;Trusted_Connection=yes;',
'SELECT GroupName, Name, DepartmentID
FROM AdventureWorks2012.HumanResources.Department
ORDER BY GroupName, Name') AS a;
GO

另請參閱 See Also

伺服器組態選項 (SQL Server) Server Configuration Options (SQL Server)
連結的伺服器 (Database Engine)
Linked Servers (Database Engine)

OPENROWSET (Transact-SQL) OPENROWSET (Transact-SQL)
OPENDATASOURCE (Transact-SQL)
OPENDATASOURCE (Transact-SQL)

sp_addlinkedserver (Transact-SQL) sp_addlinkedserver (Transact-SQL)


原文出處:ad hoc distributed queries 伺服器組態選項 - SQL Server | Microsoft Docs
前一個主題 | 下一個主題 | 頁首 | | |



Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|