cancel
Showing results for 
Search instead for 
Did you mean: 

How is the multi tenant user query supposed to work?

John_Murray
Champ in-the-making
Champ in-the-making

I'm using the Automation API to create users for isolated tenants with the multi-tenant plugin installed.

Before creating the user I check if they already exist by querying using something like this:

        Blob blob = (Blob) session.newRequest("Services.QueryUsers")
                .set("pattern", userId)
                .set("tenantId", tenantId)
                .execute();

Sadly, however, even if I have a user with that userId in that tenant I get back 0 users.

I believe that this is because of the code in QueryUsers which is part of the multi-tenant plugin. As part of the run() method there is code which does this:

        Map<String, Serializable> filter = new HashMap<String, Serializable>();
        for (String field : FULLTEXT_FIELDS) {
            filter.put(field, pattern);

            if (!StringUtils.isBlank(tenantId)) {
                filter.put("tenantId", tenantId);
            }

            users.addAll(userManager.searchUsers(filter, filter.keySet()));
        }

however I believe that the creation of the filter should be moved inside the loop like this:

         for (String field : FULLTEXT_FIELDS) {
             Map<String, Serializable> filter = new HashMap<String, Serializable>();
            filter.put(field, pattern);

            if (!StringUtils.isBlank(tenantId)) {
                filter.put("tenantId", tenantId);
            }

            users.addAll(userManager.searchUsers(filter, filter.keySet()));
        }

which will give you a match for a userId, lastname or firstName. Currently even though I use an existing userId I get nothing back as the Set used for FULLTEXT_FIELDS supplies lastname first and I am never matching that.

I've patched my version and it seems to work fine - What is the protocol for pull requests etc?

Thanks

1 REPLY 1

Thomas_Roger
Star Contributor
Star Contributor

Hi,

Thanks for the report. I've created a JIRA issue for it: NXP-16448

I will fix it according to your solution. It will be available on the next FT 7.2, and I will backport it on 6.0 also.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.