I have an ADSI connection in my SQL Server (2005) and I'm able to query it using openquery. Is there any way to create new accounts (and/or) edit existing ones?
我的SQL Server(2005)中有一个ADSI连接,我可以使用openquery查询它。有没有办法创建新帐户(和/或)编辑现有帐户?
Also, I'd like to have to use openquery to get to the data, but it looks like it's the only solution.
此外,我想使用openquery来获取数据,但它看起来是唯一的解决方案。
Here's a sample query that I'm using:
这是我正在使用的示例查询:
SELECT
samaccountname,
department,
mail,
displayName,
employeeid
FROM OPENQUERY( ADSI,
'
SELECT samaccountname, department, mail, displayName, employeeid
FROM ''LDAP://DC=MyDomainName,DC=MyDomainExtension''
WHERE objectCategory = ''Person'' and objectClass= ''user''
'
)
Thanks
2 个解决方案
#1
You can't (at least not using ADSI SQL).
你不能(至少不使用ADSI SQL)。
ADSI SQL only defines a search interface, supporting nothing more than the SELECT
statement (See MSDN: "SQL Dialect"). Also, OPENQUERY()
is the only way to get the data in SQL Server.
ADSI SQL只定义了一个搜索接口,只支持SELECT语句(参见MSDN:“SQL Dialect”)。此外,OPENQUERY()是获取SQL Server中数据的唯一方法。
To create objects, you will have to use another method (you can script against the ADSI interface quite well).
要创建对象,您必须使用另一种方法(您可以很好地针对ADSI接口编写脚本)。
#2
Please try:
SELECT top 900 *, samaccountname, department, mail,
displayName, employeeid FROM OPENQUERY( ADSI, ' SELECT
samaccountname, department, mail, displayName, employeeid FROM
''LDAP://DC=MyDomainName,DC=MyDomainExtension'' WHERE objectCategory
= ''Person'' and objectClass= ''user'' ' )
#1
You can't (at least not using ADSI SQL).
你不能(至少不使用ADSI SQL)。
ADSI SQL only defines a search interface, supporting nothing more than the SELECT
statement (See MSDN: "SQL Dialect"). Also, OPENQUERY()
is the only way to get the data in SQL Server.
ADSI SQL只定义了一个搜索接口,只支持SELECT语句(参见MSDN:“SQL Dialect”)。此外,OPENQUERY()是获取SQL Server中数据的唯一方法。
To create objects, you will have to use another method (you can script against the ADSI interface quite well).
要创建对象,您必须使用另一种方法(您可以很好地针对ADSI接口编写脚本)。
#2
Please try:
SELECT top 900 *, samaccountname, department, mail,
displayName, employeeid FROM OPENQUERY( ADSI, ' SELECT
samaccountname, department, mail, displayName, employeeid FROM
''LDAP://DC=MyDomainName,DC=MyDomainExtension'' WHERE objectCategory
= ''Person'' and objectClass= ''user'' ' )