Automatically change access level on a user in Azure DevOps

376 Views Asked by At

Is there a way to setup an automatic change of access level in Azure DevOps after a specific number of days? E.g. Setup a rule that the access level is automatically changed from "Basic + Test Plans" to "Basic" after 30 days.

Best regards

Lillian Hjelmstad

1

There are 1 best solutions below

1
On

Please follow below steps to implement this requirement.

  1. Use this Reset API: User Entitlements - Get User Entitlements to get a paged set of user entitlements, and then find the id of target user.
  2. Use this Rest API: User Entitlements - Update User Entitlement to update target user's access level. And the following request body(Content-Type: application/json-patch+json) will change the access level to Basic.
[
    {
        "from":"",
        "op":2,
        "path":"/accessLevel",
        "value":{
            "accountLicenseType":2,
            "licensingSource":1
        }
    }
]
  1. To success to call this API, you should authenticate with identity as a Project Collection Administrator or an organization Owner. You could create a PAT with full access.
  2. Create a yaml pipeline to run this API and set scheduled triggers using cron syntax.