2012-03-09 61 views
2

我聯繫我的SQL Server 2008中的Active Directory是這樣的:我可以使用鏈接的活動目錄服務器進行更新嗎?

EXEC sp_addlinkedserver 
     'ADSI', 
     'Active Directory Services 2.5', 
     'ADSDSOObject', 
     'adsdatasource' 

然後我可以查詢我喜歡這款手機的號碼:

SELECT * 
FROM OPENQUERY( 
    ADSI, 
    'SELECT DisplayName, TelephoneNumber from ''LDAP://ad1/DC=directagents,DC=local'' WHERE DisplayName=''Aaron Anodide''') 
where not DisplayName is null 
order by DisplayName 

但我一直沒能夠改變我的電話號碼,因爲這會導致一個錯誤:

SELECT * FROM 
OPENQUERY( 
    ADSI, 
    'UPDATE TelephoneNumber from ''LDAP://ad1/DC=directagents,DC=local'' SET TelephoneNumber=''136'' WHERE DisplayName=''Aaron Anodide''') 

錯誤:

Msg 7321, Level 16, State 2, Line 2
An error occurred while preparing the query...

這是可能的還是這是用於只讀訪問的想法?

回答

1

據我所知,SQL Server到Active Directory接口是隻讀的 - 您可以從AD中進行選擇,但無法更新它。

見理查德·穆勒對主題的ADO Search Tips - 他說:

Active Directory searches using ADO are very efficient. The provider retrieves records matching your query criteria in one operation, without the need to bind to many objects. However, the resulting recordset is read-only, so ADO cannot be used to modify Active Directory objects directly. If you need to modify attribute values, you will have to bind to the object.

+0

是什麼「綁定對象」的意思呢? – 2012-03-09 19:25:00

+0

在代碼中調用某些方法*將*綁定到對象 - 如果您願意,則建立對象的「連接」;不只是選擇它的一些屬性。基本的LDAP協議有一個* bind *方法,或者ADSI(AD服務接口)有一個綁定到單個對象的'GetObject'方法 – 2012-03-09 19:26:10

+0

也可能'136'與'telephoneNumber'屬性的語法不匹配,即使對象是可寫的。 – 2012-03-09 19:49:39

相關問題