Add user to an Active Directory security group using an UPDATE trigger

Can I, on an update trigger, add a user to an Active Directory security group? Please help with the T-sql. It is beyond my skills, but the need is there! thanks.

more ▼

asked Nov 10, 2009 at 01:30 PM in Default

Greg Kiker gravatar image

Greg Kiker
12 1 2 2

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

One way you could do this is by running WMI scripts through XPCmdShell in your trigger.

Read more on the WMI script here:


There are multiple issues with this, though:

  1. It will make your Updates slower because now you have to shell out, then open a trigger
  2. In most well set up SQL Server environments XPCmdShell is disabled because opens up security holes - Good luck on getting your DBA to open that one up for you.
more ▼

answered Nov 10, 2009 at 02:44 PM

Raj More gravatar image

Raj More
1.7k 80 82 84

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Nov 10, 2009 at 01:30 PM

Seen: 2900 times

Last Updated: Nov 11, 2009 at 08:47 AM