从Spring引导应用程序列出Azure Activedirectory中所有组的Rest API是什么?
(目前Google搜索带来以下两个API,如下所示,一个是“ Azure Active Directory图形API”,另一个是“ Azure API Management REST API组实体”
不确定要用于获取Azure AD组列表的确切API吗?
答案 0 :(得分:0)
最好的方法是调用Microsoft Graph API(尽管您也可以使用Azure AD Graph API进行此操作)。
对于list all groups,请求为:
GET https://graph.microsoft.com/v1.0/groups
在Java中,您可以使用Microsoft Graph SDK for Java,这是一个如何检索所有组的示例(如果您有超过999个组,则包括分页浏览多页结果):
// Set up the Graph client
IGraphServiceClient graphClient =
GraphServiceClient
.builder()
.authenticationProvider(authProvider)
.logger(new NotALogger())
.buildClient();
// Set up the initial request builder and build request for the first page
IGroupCollectionRequestBuilder groupsRequestBuilder = graphClient.groups();
IGroupCollectionRequest groupsRequest = groupsRequestBuilder
.buildRequest()
.top(999);
do {
try {
// Execute the request
IGroupCollectionPage groupsCollection = groupsRequest.get();
// Process each of the items in the response
for (Group group : groupsCollection.getCurrentPage()) {
System.out.println(group.displayName);
}
// Build the request for the next page, if there is one
groupsRequestBuilder = groupsCollection.getNextPage();
if (groupsRequestBuilder == null) {
groupsRequest = null;
} else {
groupsRequest = groupsRequestBuilder.buildRequest();
}
} catch(ClientException ex) {
// Handle failure
ex.printStackTrace();
groupsRequest = null;
}
} while (groupsRequest != null);
到list all groups the signed-in user is a member of(包括嵌套组):
POST https://graph.microsoft.com/v1.0/me/getMemberGroups
Content-type: application/json
{
"securityEnabledOnly": true
}