0 votes

Is it possible to add multiple members to a group in a singe call to the REST API? The example code only shows a single member. What would the data structure look like in that case?

by (60 points)

1 Answer

0 votes
by (2.7k points)

Hello,

There is no possibility to add multiple members in a single REST API request. You need to send a separate Add member request for each new member. For example, in PowerShell, you can iterate through an array of distinguished names and add members one by one like so:

$memberIdentifiers = @(
    "CN=John Smith,CN=Users,DC=example,DC=com",
    "CN=Mary Sue,CN=Users,DC=example,DC=com",
    "CN=John Doe,CN=Users,DC=example,DC=com"
) # TODO: modify me
$groupIdentifier = "CN=My Group,OU=Groups,DC=example,DC=com" # TODO: modify me

$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/groupMembers"

# Request parameters
$requestUrl = $baseUrl + $endpoint
$requestHeaders = @{"Adm-Authorization" = "YOUR-SECURITY-TOKEN"}

# Make requests
foreach ($dn in $memberIdentifiers)
{
    $requestBody = ConvertTo-Json @{
        "group" = $groupIdentifier;
        "newMember" = $dn
    } 

    Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl `
        -Body $requestBody -ContentType "application/json"
}

Group members are added one by one everywhere in Adaxes, even if you add multiple members in bulk in Administration console. This is done because business rules that trigger Before/after adding a member to a group need to capture each operation separately and perform their actions for each new member.

0

Ok, thank you for that detailed explanation that explains why it works the way it does. Thanks.

Related questions

0 votes
1 answer

Hello, I have my OUs structured so each department we're working with has an OU for their service accounts under their department OU. e.g. OU=Service Accounts,OU=Sales,OU= ... add each new OU to the scheduled task but I was hoping for something more hands off.

asked Oct 19, 2015 by drew.tittle (810 points)
0 votes
1 answer

When configuring web page - under "Object Selection" - you can only choose 1 location (OU) when you select "Allow selecting only AD objects located under" - is there a way to have multiple OUs instead - perhaps using a LDAP filter?

asked Feb 2, 2021 by foleyjm (20 points)
0 votes
1 answer

Hi Using Adaxes 3.13.18001.0 on Server 2019 I'm adding a self service option for our domain users to be able to add people to groups they are set as the owner of but ... everywhere? I've checked the config page a number of times and can't see anything. Thanks

asked Jan 22, 2021 by chappers77 (1.2k points)
0 votes
1 answer

They can navigate to both the user or the group within the ADAXES web interface without issue. They can then either Add to Group or Add Member but the resulting ... something to the web interface which prevents changing the lookup domain. Any ideas? Thanks!

asked Apr 9, 2020 by VTPatsFan (610 points)
0 votes
1 answer

From the Administration Console, when adding users to a group, I would like the ability to paste a list of users, like I can in ADUC. Also, I would like the ability to paste a list of groups to a user.

asked Mar 22, 2013 by Kikaida (1.1k points)
2,758 questions
2,492 answers
6,531 comments
1,470,707 users