microsoftgraph / microsoftgraph/msgraph-sdk-java
expand of appRoleAssignments on user get call yields no results
未關閉
還沒有人認領這個 Issue。
Needs: Attention :wave:
type:question
- 主要語言
- Java
- 星號
- 444
- 分支
- 154
- 平均合併
- 18 小時 28 分鐘
- 30 天內合併 PR
- 4
描述
Describe the bug
I was trying to get a user together with it's appRoleAssignments in one call. The documentation is pointing out that the expand feature for appRoleAssignments is supported. But it doesn't work.
Expected behavior
I would expect the expand to return results.
How to reproduce
User user = graphClient.usersWithUserPrincipalName(username).get(
rc -> {
rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"};
rc.queryParameters.expand = new String[]{"appRoleAssignments"};
}
);
or
graphClient.users().byUserId(username).get(
rc -> {
rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"};
rc.queryParameters.expand = new String[]{"appRoleAssignments"};
}
);
SDK Version
6.22.0
Latest version known to work for scenario above?
No response
Known Workarounds
For now I have to write this code to get it done:
var user = graphClient.usersWithUserPrincipalName(username).get(
rc -> rc.queryParameters.select = new String[]{"id", "userPrincipalName", "displayName", "givenName", "surname", "accountEnabled"}
);
user.setAppRoleAssignments(getAllAppRoleAssignments(user.getId())); // an 'expand' of appRoleAssignments in the above call gave an empty array :| ...
return user;
private List<AppRoleAssignment> getAllAppRoleAssignments(String userId) {
var result = new ArrayList<AppRoleAssignment>();
var page = graphClient.users().byUserId(userId).appRoleAssignments().get();
while (page != null) {
result.addAll(Optional.ofNullable(page.getValue()).orElse(emptyList()));
var odataNextLink = page.getOdataNextLink();
if (StringUtils.isBlank(odataNextLink)) {
break;
} else {
page = graphClient.users().byUserId(userId).appRoleAssignments().withUrl(odataNextLink).get();
}
}
return result;
}
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先,使用 appRoleAssignments 展開來重現 issue 中的兩個使用者 GET 呼叫,並將它們的回應與個別的 appRoleAssignments 要求進行比較。檢查 Graph 服務和 SDK 版本 6.22.0 是否支援文件中所述的展開行為;當組合要求傳回預期的指派,或該限制已被記錄時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- api
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 35/100