从公司 AD 中删除时删除 Azure DevOps 帐户

Remove Azure DevOps Account when remove from company AD

当帐户从公司 AD 中删除时,是否有自动(脚本或类似)方法从 Azure DevOps 中删除帐户订阅。今天这是我们公司的手动工作,效果不是很好。

如果要删除订阅的服务连接,可以使用一些RESTAPIs。

第一步。获取要删除连接的项目id

GET https://dev.azure.com/{organization}/_apis/projects/{projectName}?api-version=6.1-preview.4

第二步。获取项目中的服务连接id列表:Endpoints - Get Service Endpoints list

GET https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=6.1-preview.4

或者您可以通过其名称获取特定服务连接 ID:Endpoints - Get Service Endpoints By Names:

GET https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?endpointNames={endpointNames}&api-version=6.1-preview.4

第三步:删除服务连接:Endpoints - Delete:

DELETE https://dev.azure.com/{organization}/_apis/serviceendpoint/endpoints/{endpointId}?projectIds={projectIds}&api-version=6.1-preview.4

使用服务连接id作为{endpointId}重复这个RESTAPI.

可以快速删除多个服务连接

谢谢,这部分回答了我的问题。然而,在最好的情况下,当从 AD 中删除该帐户时,我会(自动)从 AzDO 组织中删除该帐户。例如,使用组规则不会从组织中删除用户。

也可以有一个脚本来检查用户是否是 AD 的一部分,然后如果在 AD 中不可用则从 AzDO 组织中删除。