Rob
Rob

Reputation: 2110

SQL ADSI Active Directory Create New Accounts

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

Upvotes: 3

Views: 1860

Answers (1)

Tomalak
Tomalak

Reputation: 338128

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).

Upvotes: 5

Related Questions