【问题标题】:WSO2 get user by claim valueWSO2 通过声明值获取用户
【发布时间】:2012-08-09 15:42:26
【问题描述】:

我需要知道如何通过声明值获取 wso2 用户,以执行某种搜索?

示例:

getUsersByClaimValue(String claimUri, String claimValue);

【问题讨论】:

    标签: wso2 user-management


    【解决方案1】:

    是的。此 API 方法已被引入用户存储 API 以获取与特定用户属性关联的用户名。假设您想获取“国家”属性值为“美国”的用户。那么你可以使用这个方法如下。

    getUserList("http://wso2.org/claims/country", "USA", null);

    您可以在 WSO2IS 的RemoteUserStoreManagerService 中找到此方法作为 Web 服务 API。您的 SOAP 消息如下所示。

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ws.um.carbon.wso2.org"> <soapenv:Header/> <soapenv:Body> <ser:getUserList> <ser:claimUri>http://wso2.org/claims/country</ser:claimUri> <ser:claimValue>USA</ser:claimValue> <ser:profile></ser:profile> </ser:getUserList> </soapenv:Body> </soapenv:Envelope>

    在这里,此声明 uri 是通用的,独立于用户存储。使用 WSO2 身份服务器,您可以将这些声明 uri 映射到用户存储中的任何属性。更多详情来自here

    【讨论】:

    • 感谢您的快速回答,但我在 org.wso2.carbon.user.core.UserStoreManager.class 中看不到这种方法。我应该使用另一个类吗?
    • 在上面的类中,您可以找到它作为 getUserList("wso2.org/claims/country", "USA" ,"default")。这里的第三个参数是配置文件。默认情况下,它将是“默认”配置文件。抱歉,我实际上错过了方法名称... :)...
    • 我已经尝试过了,但我每次都得到一个空的 String[]。
    • 这是 WSUserStoreManager.class 中的实现 @Override public String[] getUserList(String claim, String claimValue, String profileName) throws UserStoreException { // TODO return new String[0]; }
    • 谢谢。方法名称不正确。更新了它。但是listUser() 仅用于列出所有用户,而不是按属性搜索。这是不正确的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-05
    • 2012-07-22
    • 2017-09-22
    • 2012-07-21
    • 1970-01-01
    相关资源
    最近更新 更多