views:

826

answers:

2

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?

Also, I'd like to have to use openquery to get to the data, but it looks like it's the only solution.

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

+5  A: 

You can't (at least not using 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.

To create objects, you will have to use another method (you can script against the ADSI interface quite well).

Tomalak
A: 

you must gave over there a perfect text not this query this query is not working well