You are viewing limited content. For full access, please sign in.

Question

Question

Can Workflow be used to modify a Windows Domain Group

asked on October 7, 2022 Show version history

I can use Workflow to query a database to get a resultset with the user information I need.  From there, I am wanting to modify an active directory domain group membership by adding to the group from the result set or removing from the result set where the user is not in my resultset.  Does anyone have any experience with this?

0 0

Replies

replied on October 7, 2022

Technically you could do this with a Script/SDK Script activity in a workflow, however, you'll need an account that has sufficient rights in AD to manage group memberships, so it is important to be mindful of the security implications (i.e., who has access to Workflow).

I would say that, in general, giving the Workflow service account permissions in AD preferable to adding plain text credentials inside the workflow script code; either way security is an important consideration here (i.e., who has access to view or publish/edit workflows).

Another thing to keep in mind is that when you run a Workflow Script from the editor for testing, it is running under your account, but when it executes in a workflow instance it will be running under the service account used by Workflow.

As a result, you may see different results in testing vs running the workflow (i.e., working in one and not the other, or getting different results in one vs the other) when you're not specifying credentials in the code that connects to the DC.

I won't get into the actual code because it is probably going to vary based on your exact needs, and there's some pretty extensive resources about this available online.

The two different approaches you want to look into are:

  1. Using System.DirectoryServices and DirectoryEntry objects
  2. Using System.DirectoryServices.AccountManagement and Principal objects.

 

The second is probably ideal for your particular scenario although it does have important limitations if you start trying to get into more complex AD interactions.

Howto: (Almost) Everything In Active Directory via C# - CodeProject

System.DirectoryServices.AccountManagement Namespace | Microsoft Learn

c# - Adding and removing users from Active Directory groups in .NET - Stack Overflow

3 0
You are not allowed to follow up in this post.

Sign in to reply to this post.