Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Get-VSTeamAadGroupMembers to the module #441

Open
SebastianSchuetze opened this issue Jan 25, 2022 · 0 comments
Open

Add Get-VSTeamAadGroupMembers to the module #441

SebastianSchuetze opened this issue Jan 25, 2022 · 0 comments
Labels
feature request for new feature requests that do not just improve things

Comments

@SebastianSchuetze
Copy link
Collaborator

Add the following API to the cmdlets:

https://stackoverflow.com/questions/65710580/cannot-find-aad-group-using-identities-ado-api/65715362#65715362

It allowed to query members of an AAD group within AzDO

Execute the below API to search and get the details of the AAD group you want to add.
Request URI:

POST https://dev.azure.com/{organization}/_apis/IdentityPicker/Identities?api-version=5.0-preview.1

Request body:

{
    "query": "{AAD group name}",
    "identityTypes": ["user", "group"],
    "operationScopes": ["ims", "source"],
    "options": {
        "MinResults": 5,
        "MaxResults": 40
    },
    "properties": [
        "DisplayName",
        "IsMru",
        "ScopeName",
        "SamAccountName",
        "Active",
        "SubjectDescriptor",
        "Department",
        "JobTitle",
        "Mail",
        "MailNickname",
        "PhysicalDeliveryOfficeName",
        "SignInAddress",
        "Surname",
        "Guest",
        "TelephoneNumber",
        "Manager",
        "Description"
    ]
}

Response body:

{
    "results": [
        {
            "queryToken": "addtovsts",
            "identities": [
                {
                    "entityId": "{entityId}",
                    "entityType": "Group",
                    "originDirectory": "aad",
                    "originId": "{AAD group ID}",
                    "localDirectory": null,
                    "localId": null,
                    "displayName": "{AAD group name}",
                    "scopeName": "{AAD name}",
                    "samAccountName": null,
                    "active": null,
                    "subjectDescriptor": null,
                    "department": null,
                    "jobTitle": null,
                    "mail": "{mail}",
                    "mailNickname": "{mailNickname}",
                    "physicalDeliveryOfficeName": null,
                    "signInAddress": null,
                    "surname": null,
                    "guest": false,
                    "telephoneNumber": null,
                    "description": null,
                    "isMru": false
                }
            ],
            "pagingToken": ""
        }
    ]
}

With the details returned from previous API, execute the below API to add the AAD group to the Pull Request.
Request URI:

PUT https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/reviewers?api-version=5.0

Request body:

{
    "entityId": "{entityId}",
    "entityType": "Group",
    "active": null,
    "department": null,
    "description": null,
    "displayName": "{AAD group name}",
    "guest": false,
    "id": "{AAD group ID}",
    "isAadIdentity": true,
    "isContainer": true,
    "isHosted": true,
    "isMru": false,
    "isRequired": false,  // 'true' will set the group as the Required Reviewer, 'false' is Optional Reviewer
    "jobTitle": null,
    "localDirectory": null,
    "localId": null,
    "mail": "{mail}",  // if you did not set mail, set the value same as 'mailNickname'
    "mailNickname": "{mailNickname}",
    "originDirectory": "aad",
    "originId": "{AAD group ID}",
    "physicalDeliveryOfficeName": null,
    "samAccountName": null,
    "scopeName": "{AAD name}",
    "signInAddress": null,
    "subjectDescriptor": null,
    "surname": null,
    "telephoneNumber": null,
    "vote": 0
}
@SebastianSchuetze SebastianSchuetze added the feature request for new feature requests that do not just improve things label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request for new feature requests that do not just improve things
Projects
None yet
Development

No branches or pull requests

1 participant