You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过编程获取VSTS/TFS Online账户下所有用户信息,无需成员ID?

Fetching User Information from VSTS/TFS Online via API

Hey there! Let's break down your questions about accessing user data in VSTS/TFS Online programmatically:

1. Can I programmatically retrieve all users in a VSTS account?

Absolutely! You can use the Azure DevOps Graph REST API to pull a full list of all users in your organization. This API is built specifically for identity-related queries, making it perfect for this task.

Here's what you need to get started:

  • Permissions: You’ll need an account with Organization Reader access or higher, plus a Personal Access Token (PAT) with the Graph (Read) scope enabled.
  • API Endpoint: Use this GET request to fetch all users:
    GET https://vssps.dev.azure.com/{your-organization-name}/_apis/graph/users?api-version=7.1-preview.1
    
  • Example with curl:
    curl -u :{your-PAT} "https://vssps.dev.azure.com/MyOrg/_apis/graph/users?api-version=7.1-preview.1"
    

The response will include key details for every user, like display name, email address (mail), account name (principalName), and unique identity ID.

2. Can I fetch user info using just an account name or email (without needing member/owner IDs)?

Yes, you don’t need pre-existing member or owner IDs! The same Graph API supports filtering with the $filter parameter, which lets you target users directly by their email or account name.

Examples of filtered requests:

  • Filter by exact email:
    GET https://vssps.dev.azure.com/{your-organization-name}/_apis/graph/users?api-version=7.1-preview.1&$filter=mail eq 'user@example.com'
    
  • Filter by exact account name (principalName):
    GET https://vssps.dev.azure.com/{your-organization-name}/_apis/graph/users?api-version=7.1-preview.1&$filter=principalName eq 'DOMAIN\\username'
    
  • Fuzzy match (contains): If you need broader results (e.g., all users with "example" in their email), use the contains operator:
    GET https://vssps.dev.azure.com/{your-organization-name}/_apis/graph/users?api-version=7.1-preview.1&$filter=contains(mail, 'example')
    

Authenticate with your PAT just like the full user list request, and the response will return only the matching user(s) with the details you need (account name, email, etc.).

内容的提问来源于stack exchange,提问作者SK Alvaro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:35:59