使用 OpenSSO 客户端 SDK 获取所有 ActiveDirectory 组

发布于 2024-09-06 09:16:11 字数 885 浏览 8 评论 0原文

我希望这里有人有使用 Sun OpenSSO(现在的 ForgeRock OpenAM)的经验。

我正在尝试使用 Java/JBoss EAP 5.0 中的 OpenSSO 客户端 SDK 获取 ActiveDirectory 中的所有组。

我通过组合我可以在网络上找到的各种示例和代码片段尝试了以下操作,但这失败并最终记录“不允许用户以外的身份的成员身份”。基本方法是使用 AMIdentityRepository -> getRealmIdentity() ->; getMemberships(IdType.GROUP) :

SSOTokenManager manager = SSOTokenManager.getInstance();
String tokenString = URLDecoder.decode(tokenID, "ISO-8859-1");
SSOToken token = manager.createSSOToken(tokenString);
if (manager.isValidToken(token)) {
    SSOToken adminToken = (SSOToken)AccessController.
        doPrivileged(AdminTokenAction.getInstance());
 AMIdentityRepository rep = new AMIdentityRepository(adminToken, "/");
 AMIdentity identity = rep.getRealmIdentity();
 Set groups = identity.getMemberships(IdType.GROUP);
}

注意我不是试图确定用户是否是组的成员或检索用户的组 - 我正在尝试获取所有组的列表。

任何建议将不胜感激 - 谢谢!

I hope someone here has experience with Sun OpenSSO (now ForgeRock OpenAM).

I'm trying to get all groups in ActiveDirectory using the OpenSSO Client SDK in Java / JBoss EAP 5.0.

I tried the following by combining various samples and code snippets I could find on the web, but this fails and eventually logs "Memberships for identities other than Users is not allowed." The basic approach was to use AMIdentityRepository -> getRealmIdentity() -> getMemberships(IdType.GROUP) :

SSOTokenManager manager = SSOTokenManager.getInstance();
String tokenString = URLDecoder.decode(tokenID, "ISO-8859-1");
SSOToken token = manager.createSSOToken(tokenString);
if (manager.isValidToken(token)) {
    SSOToken adminToken = (SSOToken)AccessController.
        doPrivileged(AdminTokenAction.getInstance());
 AMIdentityRepository rep = new AMIdentityRepository(adminToken, "/");
 AMIdentity identity = rep.getRealmIdentity();
 Set groups = identity.getMemberships(IdType.GROUP);
}

Note I'm not trying to determine if a user is a member of a group or to retrieve a user's groups - I'm trying to get a list of ALL groups.

Any suggestions would be appreciated - thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在巴黎塔顶看东京樱花 2024-09-13 09:16:11

不要使用rep.getRealmIdentity(),然后调用getMemberships(IdType.GROUP),而是使用searchIdentities和getSearchResults,例如:

SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
AMIdentityRepository ir = new AMIdentityRepository(token, "/");
IdSearchResults results = ir.searchIdentities(IdType.GROUP, "*", new IdSearchControl());
Set<AMIdentity> groups = results.getSearchResults();    
for (AMIdentity group : groups) {
    logger.debug("Group Name : " + group.getName());
}

Instead of rep.getRealmIdentity() and then calling getMemberships(IdType.GROUP), use searchIdentities and getSearchResults like:

SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
AMIdentityRepository ir = new AMIdentityRepository(token, "/");
IdSearchResults results = ir.searchIdentities(IdType.GROUP, "*", new IdSearchControl());
Set<AMIdentity> groups = results.getSearchResults();    
for (AMIdentity group : groups) {
    logger.debug("Group Name : " + group.getName());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文