> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/ldap/addusertogroups.md).

# AddUserToGroups

Add user to Active Directory groups.

Task version: 2.1.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.LDAP>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                                  | Description                                                                                                                                                                                                                                                                                   |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| UserDistinguishedName : `String`      | <p>User's distinguished name (DN)</p><p><br>Default: <code>-</code><br>Example: <code>CN=Tes Tuser,ou=users,dc=wimpi,dc=net</code></p>                                                                                                                                                        |
| GroupDistinguishedNames : `String[]`  | <p>Group distinguished name(s) (DN) to add the user to. Can specify one or multiple groups.</p><p><br>Default: <code>-</code><br>Example: <code>new\[] { "cn=admin,ou=roles,dc=wimpi,dc=net", "cn=developers,ou=roles,dc=wimpi,dc=net" }</code></p>                                           |
| UserExistsAction : `UserExistsAction` | <p>Handle user exists exception.</p><p>Possible values:</p><ul><li><code>Throw</code>: Throw an error.</li><li><code>Skip</code>: Do nothing and add LDAP error message to the task's result.</li></ul><p><br>Default: <code>Throw</code><br>Example: <code>UserExistsAction.Throw</code></p> |
| {% endtab %}                          |                                                                                                                                                                                                                                                                                               |

{% tab title="Connection" %}

| Name                          | Description                                                                                                                                                                                                                 |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Host : `String`               | <p>LDAP server host.</p><p>This must resolve to a Domain Controller (FQDN) in the same domain</p><p>as the target group being modified.</p><p><br>Default: <code>-</code><br>Example: <code>dc1.emea.company.com</code></p> |
| Port : `Int32`                | <p>Port. Value 0 = use LDAP/LDAPS default port which is 389 or 636 depending on (SecureSocketLayer) and (TLS).</p><p><br>Default: <code>0</code><br>Example: <code>389</code></p>                                           |
| SecureSocketLayer : `Boolean` | <p>Perform secure operation.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                            |
| TLS : `Boolean`               | <p>Connection is protected by TLS.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                      |
| User : `String`               | <p>User.</p><p><br>Default: <code>-</code><br>Example: <code>Foo</code></p>                                                                                                                                                 |
| 🗝Password : `String`         | <p>Password.</p><p><br>Default: <code>-</code><br>Example: <code>Bar123</code></p>                                                                                                                                          |
| {% endtab %}                  |                                                                                                                                                                                                                             |
| {% endtabs %}                 |                                                                                                                                                                                                                             |

## Task Result

| Name                                | Description                                                                                                                                                                                                                                                                                                        |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Success : `Boolean`                 | <p>Update completed.<br>Example: <code>true</code></p>                                                                                                                                                                                                                                                             |
| Error : `String`                    | <p>LDAP Error message. Only populated when operation fails.<br>Example: <code>Entry Already Exists</code></p>                                                                                                                                                                                                      |
| Details : `String`                  | <p>Operation details. Contains information about added and skipped groups when applicable.<br>Example: <code>Added to 2 group(s): cn=admin,ou=roles,dc=wimpi,dc=net, cn=managers,ou=roles,dc=wimpi,dc=net. Skipped 1 group(s): cn=developers,ou=roles,dc=wimpi,dc=net: User already exists in the group</code></p> |
| UserDistinguishedName : `String`    | <p>User DN.<br>Example: <code>CN=Tes Tuser,ou=users,dc=wimpi,dc=net</code></p>                                                                                                                                                                                                                                     |
| GroupDistinguishedName : `String[]` | <p>Group DN(s).<br>Example: <code>new\[] { "cn=admin,ou=roles,dc=wimpi,dc=net" }</code></p>                                                                                                                                                                                                                        |

## Task Changelog

Changelog for Task Frends.LDAP.AddUserToGroups.

### \[2.1.0] - 2026-02-03

#### Changed

* Improved documentation for Host parameter usage

### \[2.0.0] - 2026-01-29

#### Changed

* \[Breaking] Input: Changed GroupDistinguishedName (string) to GroupDistinguishedNames (string\[]) to support adding users to multiple groups in a single operation.
* Result: Added Details property for operation details. Error now only contains error messages for failures.

### \[1.2.0] - 2025-11-20

#### Fixed

* Fixed LDAP exception when adding duplicate users with skip option enabled.

### \[1.1.0] - 2025-08-13

#### Fixed

* Fixed KeyNotFoundException when checking empty groups for existing users.

### \[1.0.1] - 2024-03-01

#### Fixed

* Fixed issue with UserExistsAction parameter when AD returned another error message by adding method to actually check if the user is in the group.

### \[1.0.0] - 2022-10-07

#### Added

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/ldap/addusertogroups.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
