我将我的 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
准备查询时发生错误...
这是可能的还是将其用于只读访问的想法?