Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7EA8F200BDC for ; Wed, 14 Dec 2016 09:39:01 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7D569160B19; Wed, 14 Dec 2016 08:39:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A5C12160B13 for ; Wed, 14 Dec 2016 09:39:00 +0100 (CET) Received: (qmail 54349 invoked by uid 500); 14 Dec 2016 08:38:54 -0000 Mailing-List: contact users-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@directory.apache.org Delivered-To: mailing list users@directory.apache.org Received: (qmail 54238 invoked by uid 99); 14 Dec 2016 08:38:54 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Dec 2016 08:38:54 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 0DCF31A0357 for ; Wed, 14 Dec 2016 08:38:54 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.898 X-Spam-Level: * X-Spam-Status: No, score=1.898 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id NksywC7hjejw for ; Wed, 14 Dec 2016 08:38:52 +0000 (UTC) Received: from mail-vk0-f47.google.com (mail-vk0-f47.google.com [209.85.213.47]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 4475D5F46F for ; Wed, 14 Dec 2016 08:38:52 +0000 (UTC) Received: by mail-vk0-f47.google.com with SMTP id 137so17988314vkl.0 for ; Wed, 14 Dec 2016 00:38:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=i2nyK8l3RGRl6AgWq8Mp1REXUPNQ6Ga2U9P8DPFG6V4=; b=Tvhcil3ZuAUPYJ+A+7O8MeOL/Ee9LgaHI0jsmBP/eO5Vuu3qxxtGwUgDMFyHgJs/zr Caqd3IUhx5V5tGLjPQf/YL+f610GilshhpTB/9f0X9sw1EkI71treC34WiTok6CnA4DV LwH23eac9RTCKt27nqfozrPYTs1tB1NtbA+MGiq+2+vTr84y66p1SU1eq9u1pXLtSP6W DXDWU5YkRiUY2MSP/mqOqs+/hwuNWbo1PtYfEPkEGkceaDvV4wt0lJ5x5Lcgn6K5DA7H 0X6ccgOFlBL9lTLA4f1ilmLY+LnaVyPRls607haNsyirNTHbbmunQTVJ+pXluMZgsdih TsvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=i2nyK8l3RGRl6AgWq8Mp1REXUPNQ6Ga2U9P8DPFG6V4=; b=T87J4urLwqmbnw0hveeeY6o/8xNJ7Og8Nb97V9uqY3JSh3WIvP8puTRw9o52D1xmxW sCSMq9+Nr4d/KcIrt/4jb0zJsnP2r7fexa5AsYnPnzjqxOtJLFVp+KqyUbD2Z2lx+CMo tJqGBq+2mm8U9FA18KTIw/krrUUOFg6VVMEMvE6eTMTr7ysUnHIz69NfpD4JGdhOhDu6 GaD+mMCShYcymOW/CBa+X8BSVY7ObAuWmTszKtkBFxUakyQzJFa2jYIYSwpA5+UqsBaT bm9NSjP7EXwwMdvrXX84y1wZIa0iE+I3ka6KEiBjcrQuia4PLz4Ri5houe6ZzQb0UX7p 08ag== X-Gm-Message-State: AKaTC00sKl3q53+Ufl3UFPTSfudgEUOJy+IBjssDv1Orjd391mMDljgbvedhwU5sl1WhGvyOMJGJ0Whbs3oOMw== X-Received: by 10.159.35.108 with SMTP id 99mr85027197uae.4.1481704731296; Wed, 14 Dec 2016 00:38:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.129.13 with HTTP; Wed, 14 Dec 2016 00:38:50 -0800 (PST) In-Reply-To: References: From: Greg Thomas Date: Wed, 14 Dec 2016 08:38:50 +0000 Message-ID: Subject: Re: Mapping hierarchical models To: users@directory.apache.org Content-Type: multipart/alternative; boundary=001a113540922bc9cb05439a44a6 archived-at: Wed, 14 Dec 2016 08:39:01 -0000 --001a113540922bc9cb05439a44a6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > when you need to get back 2 different > informations from a LDAP server, you need to send 2 different LDAP > requests. That was the conclusion I came too, as well. > LDAP accepts multi-value > attributes, so you can imagine adding the equipements into a dedicated > AttributeType in a version of person. Unfortunately I don't have control of the schema (I've also over-simplified it for the purposes of the example). I think the tactic we're going to go for is; a) Find all the people, create objects for them. b) Find all the equipment, create objects for them. We know which person each item is for from the DN, as we can add each equipment object to the appropriate person object. It's two queries, but a lot quicker than on query for each person. Thanks, Greg On 13 December 2016 at 20:25, Emmanuel L=C3=A9charny = wrote: > > > Le 13/12/16 =C3=A0 18:26, Greg Thomas a =C3=A9crit : > > Firstly, apologies for all the recent questions. I recently started > looking > > at our LDAP code, and would like to migrate away from JNDI, The Apache > LDAP > > API seems like the way to go, but I'm having fun with the API. > > > > Secondly, can I say congratulations on all the good work that you've > done; > > the API seems streets ahead of JNDI, and it makes it /much/ easier to > use. > > > > Finally, my question. Our LDAP server is, from the client we're > > considering, read-only - so I'm only interesting in reading information > out > > of it. It models what I suspect is a fairly normal hierarchy of objects= . > > For simplicity, let's assume it models equipment that people are > > responsible for, which is close enough to explain my problem. So > > conceptually, we may have > > > > Alice (objectclass=3Dperson) > > | > > +--> PC (objectclass=3Dequipment) > > +--> Monitor (objectclass=3Dequipment) > > +--> Phone (objectclass=3Dequipment) > > > > Bob > > | > > +--> PC (objectclass=3Dequipment) > > +--> Monitor (objectclass=3Dequipment) > > +--> Phone (objectclass=3Dequipment) > > > > etc. etc. > > > > Now, I can find just the people > > > > connectionTemplate.search(baseDn.add("ou=3Dpeople"), > "(objectClass=3D*person* > > *)"*, SearchScope.ONELEVEL, PERSON_MAPPER); > > > > I can also find just the equipment > > > > connectionTemplate.search(baseDn.add("ou=3Dpeople").add("ou=3Dequipment= "), > > "(objectClass=3Dequipment*)"*, SearchScope.ONELEVEL, EQUIPMENT_MAPPER); > > > > Is there a way I could use an EntryMapper to somehow map both people an= d > > equipment in the one search? Something like ... > > > > connectionTemplate.search(baseDn.add("ou=3Dpeople"), > "(|(objectClass=3D*person* > > )(objectClass=3Dequipment*))"*, SearchScope.SUBTREE, > > PEOPLE_AND_EQUIPMENT_MAPPER); > > > > Although that does pass in a sequence of Entry objects to the mapper, t= he > > order is "all the people" followed by "all the equipment". Unless I've > > missed something, there's no easy way to add the equipment to the perso= n > as > > part of the mapper - i.e. it has to be done as part of a two part > process; > > find all the people, find all the equioment, and then assign the > equipment > > back to the people. > > > > Have I missed anything here? > > Hi Greg, > > Lucas, please correct me if I'm wrong. > > LDAP does not do any joint, so when you need to get back 2 different > informations from a LDAP server, you need to send 2 different LDAP > requests. Here, it's even worse, because youc an get all the users in > one single request, but you will have to iterate on all the result > etries in order to grab the sub entries containing their equipement, one > by one. > > This is clearly not efficient. > > Now, you should consider another path : LDAP accepts multi-value > attributes, so you can imagine adding the equipements into a dedicated > AttributeType in a version of person. Of course, if you need to add some > more informations related to each equipement, you will have to augment > your person ObjectClass up to a point it becomes quite coplicated to > manage. > > > -- > Emmanuel Lecharny > > Symas.com > directory.apache.org > > --001a113540922bc9cb05439a44a6--