<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: multi tenant LDAP user isolation in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321490#M8491</link>
    <description>&lt;P&gt;I'm interested in the answer as well, any clue?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Oct 2014 08:55:41 GMT</pubDate>
    <dc:creator>promanov_</dc:creator>
    <dc:date>2014-10-07T08:55:41Z</dc:date>
    <item>
      <title>multi tenant LDAP user isolation</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321488#M8489</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I'm using nuxeo 5.8HF10 in combination with LDAP.&lt;/P&gt;
&lt;P&gt;I'm experiencing the following situation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;usera - tenantA
userb - tenantB
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;usera is a tenantA administrator.
When searching in the admin center (users&amp;amp;groups) userb appears in the list.&lt;/P&gt;
&lt;P&gt;How can we isolate the users?&lt;/P&gt;
&lt;P&gt;I'm using the following LDAP configuration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;fieldMapping name="username"&amp;gt;email&amp;lt;/fieldMapping&amp;gt;
&amp;lt;fieldMapping name="password"&amp;gt;userpass&amp;lt;/fieldMapping&amp;gt;
&amp;lt;fieldMapping name="firstName"&amp;gt;name&amp;lt;/fieldMapping&amp;gt;
&amp;lt;fieldMapping name="lastName"&amp;gt;secondname&amp;lt;/fieldMapping&amp;gt;
&amp;lt;fieldMapping name="company"&amp;gt;organisation&amp;lt;/fieldMapping&amp;gt;
&amp;lt;fieldMapping name="tenantId"&amp;gt;organisation&amp;lt;/fieldMapping&amp;gt;
&amp;lt;fieldMapping name="email"&amp;gt;email&amp;lt;/fieldMapping&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think it is somewhere in the LDAP part, as running on a local machine without the LDAP it seems to work fine.&lt;/P&gt;
&lt;P&gt;Do I need to configure the LDAP somehow different?&lt;/P&gt;
&lt;P&gt;Thanks in advance,
Bauke Roo&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;I've started working on this again and made some progress.
It seems it is not needed to implement a new usermanager. The first change I made is a new operation based SuggestUserEntries.java, adding a filter in the run method. The code is at the bottom of this post.&lt;/P&gt;
&lt;P&gt;I'm still experiencing an issue in the admin panel when searching for users these seem to be multi-tenant fit yet. the following ajax call is made to /nuxeo/view_admin.faces:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;AJAX:EVENTS_COUNT	1
AJAXREQUEST	usersListingView:search_users_region
autoScroll	
javax.faces.ViewState	j_id7
usersListingView:searchFo...	usersListingView:searchForm
usersListingView:searchFo...	usersListingView:searchForm
usersListingView:searchFo...	Search
usersListingView:searchFo...	test
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I cannot find in which class this call/method is executed, can someone please help?&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;update
The search seems to be executed in the org.nuxeo.ecm.platform.usermanager.providers.UsersPageProvider&lt;/P&gt;
&lt;P&gt;My plan is to create a new page provider in order to add a filter in the methods.
The question now is:
How can I get the tenantId of the users in this pageProvider?&lt;/P&gt;
&lt;P&gt;I've tried passing it in the pageproviders-contrib.xml:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; &amp;lt;extension target="org.nuxeo.ecm.platform.query.api.PageProviderService"
    point="providers"&amp;gt;

    &amp;lt;genericPageProvider name="users_listing"
      class="org.nuxeo.capgemini.LDAPMultiTenancyPageProvider"&amp;gt;
      &amp;lt;pageSize&amp;gt;20&amp;lt;/pageSize&amp;gt;
      &amp;lt;property name="tenantId"&amp;gt;#{currentUser.tenantId}&amp;lt;/property&amp;gt;
    &amp;lt;/genericPageProvider&amp;gt;
   &amp;lt;/extension&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However this just returns #{currentUser.tenantId} in the java code.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Is there a way to get the userInfo in a pageprovider?&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;code below&lt;/P&gt;
&lt;P&gt;Custom method for the new operation based on SuggestUserEntries.java:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; @OperationMethod
    public Blob run() throws ClientException {
    	
    	if(prefix.isEmpty())
    	{
    		prefix = searchTerm;
    	}
        JSONArray result = new JSONArray();
        boolean isGroupRestriction = !StringUtils.isBlank(groupRestriction);
        boolean groupOnly = false;
        boolean userOnly = isGroupRestriction;

        if (!isGroupRestriction &amp;amp;&amp;amp; searchType != null &amp;amp;&amp;amp; !searchType.isEmpty()) {
            if (searchType.equals(Select2Common.USER_TYPE)) {
                userOnly = true;
            } else if (searchType.equals(Select2Common.GROUP_TYPE)) {
                groupOnly = true;
            }
        }
        try {
            ArrayList&amp;lt;DocumentModel&amp;gt; userList = new ArrayList&amp;lt;DocumentModel&amp;gt;();
            DocumentModelList groupList = null;
            if (!groupOnly) {
            	log.info("userManager: "+userManager.getUserSchemaName());
                Schema schema = schemaManager.getSchema(userManager.getUserSchemaName());
                
                //changed this
                MultiTenantPrincipal principal = (MultiTenantPrincipal) ctx.getPrincipal();
                String tenantId = principal.getTenantId();
                
                for (String field : FULLTEXT_FIELDS) {
                    Map&amp;lt;String, Serializable&amp;gt; filter = new HashMap&amp;lt;String, Serializable&amp;gt;();
                    filter.put(field, prefix);

                    if (!StringUtils.isBlank(tenantId)) {
                        filter.put("tenantId", tenantId);
                    }

                    userList.addAll(userManager.searchUsers(filter, filter.keySet()));
                    
                }
                userList = removeDuplicates(userList);
                //changed this
                
                
                Directory userDir = directoryService.getDirectory(userManager.getUserDirectoryName());
                for (DocumentModel user : userList) {
                    JSONObject obj = new JSONObject();
                    for (Field field : schema.getFields()) {
                        QName fieldName = field.getName();
                        String key = fieldName.getLocalName();
                        Serializable value = user.getPropertyValue(fieldName.getPrefixedName());
                        if (key.equals(userDir.getPasswordField())) {
                            continue;
                        }
                        obj.element(key, value);
                    }
                    String userId = user.getId();
                    obj.put(Select2Common.ID, userId);
                    obj.put(Select2Common.TYPE_KEY_NAME,
                            Select2Common.USER_TYPE);
                    obj.put(Select2Common.PREFIXED_ID_KEY_NAME,
                            NuxeoPrincipal.PREFIX + userId);
                    Select2Common.computeUserLabel(obj, firstLabelField,
                            secondLabelField, thirdLabelField, hideFirstLabel,
                            hideSecondLabel, hideThirdLabel,
                            displayEmailInSuggestion, userId);
                    Select2Common.computeUserGroupIcon(obj, hideIcon);
                    if (isGroupRestriction) {
                        // We need to load all data about the user particularly
                        // its
                        // groups.
                        user = userManager.getUserModel(userId);
                        UserAdapter userAdapter = user.getAdapter(UserAdapter.class);
                        List&amp;lt;String&amp;gt; groups = userAdapter.getGroups();
                        if (groups != null &amp;amp;&amp;amp; groups.contains(groupRestriction)) {
                            result.add(obj);
                        }
                    } else {
                        result.add(obj);
                    }
                }
            }
            if (!userOnly) {
                Schema schema = schemaManager.getSchema(userManager.getGroupSchemaName());
                groupList = userManager.searchGroups(prefix);
                for (DocumentModel group : groupList) {
                    JSONObject obj = new JSONObject();
                    for (Field field : schema.getFields()) {
                        QName fieldName = field.getName();
                        String key = fieldName.getLocalName();
                        Serializable value = group.getPropertyValue(fieldName.getPrefixedName());
                        obj.element(key, value);
                    }
                    String groupId = group.getId();
                    obj.put(Select2Common.ID, groupId);
                    // If the group hasn't an label, let's put the groupid
                    Select2Common.computeGroupLabel(obj, groupId,
                            userManager.getGroupLabelField(), hideFirstLabel);
                    obj.put(Select2Common.TYPE_KEY_NAME,
                            Select2Common.GROUP_TYPE);
                    obj.put(Select2Common.PREFIXED_ID_KEY_NAME,
                            NuxeoGroup.PREFIX + groupId);
                    Select2Common.computeUserGroupIcon(obj, hideIcon);
                    result.add(obj);
                }
            }

            // Limit size results.
            int userSize = userList != null ? userList.size() : 0;
            int groupSize = groupList != null ? groupList.size() : 0;
            int totalSize = userSize + groupSize;
            if (userSuggestionMaxSearchResults != null
                    &amp;amp;&amp;amp; userSuggestionMaxSearchResults &amp;gt; 0) {
                if (userSize &amp;gt; userSuggestionMaxSearchResults
                        || groupSize &amp;gt; userSuggestionMaxSearchResults
                        || totalSize &amp;gt; userSuggestionMaxSearchResults) {
                    throw new SizeLimitExceededException();
                }
            }

        } catch (SizeLimitExceededException e) {
            return searchOverflowMessage();
        }

        return new StringBlob(result.toString(), "application/json");
    }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Apr 2014 15:43:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321488#M8489</guid>
      <dc:creator>Bauke_Roo</dc:creator>
      <dc:date>2014-04-08T15:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: multi tenant LDAP user isolation</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321489#M8490</link>
      <description>&lt;P&gt;no reply, why?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2014 15:13:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321489#M8490</guid>
      <dc:creator>Esheng_</dc:creator>
      <dc:date>2014-04-14T15:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: multi tenant LDAP user isolation</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321490#M8491</link>
      <description>&lt;P&gt;I'm interested in the answer as well, any clue?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2014 08:55:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321490#M8491</guid>
      <dc:creator>promanov_</dc:creator>
      <dc:date>2014-10-07T08:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: multi tenant LDAP user isolation</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321491#M8492</link>
      <description>&lt;P&gt;For now it seems it is not possible. I believe that in order to make this work a new usermanagerImpl class has to be written.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2014 09:16:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321491#M8492</guid>
      <dc:creator>Bauke_Roo</dc:creator>
      <dc:date>2014-10-07T09:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: multi tenant LDAP user isolation</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321492#M8493</link>
      <description>&lt;P&gt;thanks for your feedback&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2014 15:08:24 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321492#M8493</guid>
      <dc:creator>promanov_</dc:creator>
      <dc:date>2014-10-07T15:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: multi tenant LDAP user isolation</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321493#M8494</link>
      <description>&lt;P&gt;I'm new to Nuxeo and also interested in this question and since it's already almost 3 years old, I wonder if anything has changed? Can I use a different Active Directory server for each tenant (without writing custom implementations from scratch)? Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:53:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/multi-tenant-ldap-user-isolation/m-p/321493#M8494</guid>
      <dc:creator>mathias_lin</dc:creator>
      <dc:date>2017-01-24T15:53:11Z</dc:date>
    </item>
  </channel>
</rss>

