3

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

Kev
  • 118,037
  • 53
  • 300
  • 385
Rob
  • 2,080
  • 4
  • 28
  • 48
  • @kev: This is a system wide edit/change. Do not rollback. – GEOCHET Mar 10 '09 at 02:12
  • RichB - so who decided you could make a global change to what was already the more popular of the two tags to something less people were using? – Kev Mar 10 '09 at 02:44
  • @RichB - more people using 'activedirectory' over 'active-directory' would seem to be a consensus which you are always so keen to use as one of your usual excuses. – Kev Mar 10 '09 at 02:46
  • @Kev: The rules are very clear. Seperate words with a - in the tags. Active Directory is two words. – GEOCHET Mar 10 '09 at 03:11
  • And your excuse for replacing the I'm contraction? – Kev Mar 10 '09 at 03:13
  • @RichB - http://stackoverflow.com/questions/229784/tips-for-effectively-tagging-questions - "Do not re-tag only to change the format of the tag (ie: stackoverflow -> stack-overflow). This is done automatically by the community user." – Kev Mar 10 '09 at 03:17
  • @Kev: The community user is somewhat dead. Hasn't worked in a while. – George Stocker Mar 10 '09 at 03:23
  • @Rich B & Kev: Are you two serious about your little edit war? Honestly, isn't it completely irrelevant if it is "I'm or "I am"? – Tomalak Mar 11 '09 at 12:15
  • @Rich B: Editing other peoples posts to change something at this level of insignificance steals them one opportunity to add something *relevant* before their post is turned into a wiki and cannot earn them rep anymore. Maybe (just maybe) you are taking this editing business a little too seriously. – Tomalak Mar 11 '09 at 12:20
  • @Tomalak: That is not how CW works, and this has nothing to do with my edits. Thanks anyway. – GEOCHET Mar 11 '09 at 20:39
  • @Kev @Rich B: Please end these rollback wars – Geoff Dalgas Mar 11 '09 at 20:45

1 Answers1

5

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
  • 332,285
  • 67
  • 532
  • 628