-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
Description
Description of the new feature - must be an in-depth explanation of the feature you want, reasoning why, and the added benefits for MSPs as a whole.
Having the newly added "Add to group" and "Remove from group" buttons as muti selects in the Edit user page would be very useful, and would complete the ablity to do most of the group fandangeling for the user, in the same place.
I have tried myself but the solution was not good enough. Couldnt figure out how to pass the calculatedGroupType into the backend as it's own value/parameter.
I have attached the code below if it's of any use :)
PowerShell commands you would normally use to achieve above request
Add this import
import { useListGroupsQuery } from 'src/store/api/groups'
Add this under the EditUser const
const {
data: groups = [],
isFetching: groupsIsFetching,
error: groupsError,
} = useListGroupsQuery({ tenantDomain })
Add these lines under shippedValues:
AddToGroups: Array.isArray(values.AddToGroups) ? values.AddToGroups : [],
RemoveFromGroups: Array.isArray(values.RemoveFromGroups) ? values.RemoveFromGroups : [],
Add this just above the "Copy group membership from other user"
<CCol md={12}>
<RFFSelectSearch
multi={true}
label="Add user to group"
disabled={formDisabled}
values={groups?.map((group) => ({
value: group.id,
name: `${group.displayName} - ${group.calculatedGroupType} `,
groupType: group.calculatedGroupType,
}))}
placeholder={!groupsIsFetching ? 'Select groups' : 'Loading...'}
name="AddToGroups"
/>
{groupsError && <span>Failed to load list of groups</span>}
</CCol>
<CCol md={12}>
<RFFSelectSearch
multi={true}
label="Remove user from group"
disabled={formDisabled}
values={groups?.map((group) => ({
value: group.id,
name: `${group.displayName} - ${group.calculatedGroupType} `,
groupType: group.calculatedGroupType,
}))}
placeholder={!groupsIsFetching ? 'Select groups' : 'Loading...'}
name="RemoveFromGroups"
/>
{groupsError && <span>Failed to load list of groups</span>}
</CCol>
Add to "Invoke-EditUser-ps1"
if ($Request.body.AddToGroups -ne '') {
$Request.body.AddToGroups | ForEach-Object {
try {
Write-Host 'Adding to groups IM IN HERE'
Write-Host $_.groupType
$UserBody = [PSCustomObject]@{
'@odata.id' = "https://graph.microsoft.com/beta/directoryObjects/$($UserObj.Userid)"
}
$UserBodyJSON = ConvertTo-Json -Compress -Depth 10 -InputObject $UserBody
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$($_.value)/members/`$ref" -tenantid $Userobj.tenantid -type POST -body $UserBodyJSON -Verbose
} catch {
$Params = @{ Identity = $_.value; Member = $UserObj.Userid; BypassSecurityGroupManagerCheck = $true }
New-ExoRequest -tenantid $Userobj.tenantid -cmdlet 'Add-DistributionGroupMember' -cmdParams $params -UseSystemMailbox $true
}
}
}
Metadata
Metadata
Assignees
Labels
Projects
Status
Done