-
Notifications
You must be signed in to change notification settings - Fork 20
/
ims_query.rs
47 lines (38 loc) · 1.2 KB
/
ims_query.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// ims_query.rs
// Identity query example.
use anyhow::Result;
use azure_devops_rust_api::ims;
use std::env;
mod utils;
#[tokio::main]
async fn main() -> Result<()> {
// Get authentication credential
let credential = utils::get_credential()?;
// Get ADO configuration via environment variables
let organization = env::var("ADO_ORGANIZATION").expect("Must define ADO_ORGANIZATION");
let user_email = env::args()
.nth(1)
.expect("Usage: identity_query <email_address>");
// Create an "ims" client
let ims_client = ims::ClientBuilder::new(credential).build();
// Query the specified user
let identities = ims_client
.identities_client()
.read_identities(organization)
.search_filter("General")
.filter_value(&user_email)
.await?
.value;
println!("Found {} identities", identities.len());
for identity in &identities {
if let Some(id) = &identity.identity_base.id {
println!("{id} {user_email}");
}
}
if let Some(identity) = identities.first() {
println!("{:#?}", identity);
}
Ok(())
}