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 124DF200C14 for ; Tue, 7 Feb 2017 21:01:10 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0F12E160B3E; Tue, 7 Feb 2017 20:01:10 +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 31658160B32 for ; Tue, 7 Feb 2017 21:01:09 +0100 (CET) Received: (qmail 50657 invoked by uid 500); 7 Feb 2017 20:01:08 -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 50646 invoked by uid 99); 7 Feb 2017 20:01:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2017 20:01:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 99047C2371 for ; Tue, 7 Feb 2017 20:01:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3 X-Spam-Level: *** X-Spam-Status: No, score=3 tagged_above=-999 required=6.31 tests=[RDNS_NONE=3] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id gojfbhGcrLO2 for ; Tue, 7 Feb 2017 20:01:06 +0000 (UTC) Received: from zimbra.rez1.com (unknown [65.200.132.12]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id B9C555F254 for ; Tue, 7 Feb 2017 20:01:05 +0000 (UTC) Received: from zimbra.rez1.com (localhost [127.0.0.1]) by zimbra.rez1.com (Postfix) with ESMTPS id E8E2227F34E; Tue, 7 Feb 2017 15:00:57 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by zimbra.rez1.com (Postfix) with ESMTP id DA78227F34C; Tue, 7 Feb 2017 15:00:57 -0500 (EST) Received: from zimbra.rez1.com ([127.0.0.1]) by localhost (zimbra.rez1.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UwaWBnf1516s; Tue, 7 Feb 2017 15:00:57 -0500 (EST) Received: from zimbra.rez1.com (zimbra.rez1.com [10.20.120.18]) by zimbra.rez1.com (Postfix) with ESMTP id C626727F32A; Tue, 7 Feb 2017 15:00:57 -0500 (EST) From: Mike Davis To: , "s_humbi" References: <41a09471-643c-f924-7ed1-6833876e77d9@gmail.com> <080201d27d74$18d164a0$4a742de0$@rez1.com> <68d90bd1-5990-6547-dc05-efd4f703b52c@gmail.com> <1726711339.4276068.1486461378855@mail.yahoo.com> In-Reply-To: <1726711339.4276068.1486461378855@mail.yahoo.com> Subject: RE: Exploring triggers Date: Tue, 7 Feb 2017 15:00:57 -0500 (EST) Message-ID: <0a2901d2817c$e5b6dca0$b12495e0$@rez1.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Mailer: Microsoft Outlook 15.0 X-Mailer: Zimbra 8.6.0_GA_1153 (ZimbraConnectorForOutlook/8.6.0.1307) Thread-Index: e8GJwsemayaV6g6YngauFKvDSAFGuw== Content-Language: en-us Thread-Topic: Exploring triggers Content-Transfer-Encoding: quoted-printable archived-at: Tue, 07 Feb 2017 20:01:10 -0000 Do you have an example of a working trigger that actually alters things o= n=20 the LDAP server? That's where I got hung up. I did much like you did, but= =20 what I really wanted was to alter an entry when the trigger fired. I didn't have any issues with the trigger subentries disappearing. Your=20 process reads a lot like mine. What version of Apache DS are you running?= =20 Maybe there was a change between your version and mine? -----Original Message----- From: s_humbi [mailto:s_humbi@yahoo.com.INVALID] Sent: Tuesday, February 07, 2017 4:56 AM To: users@directory.apache.org Subject: Re: Exploring triggers I was playing around a little bit with triggers and stored procedures. For me (as beginner) almost everything worked fine, except this big probl= em=20 (don't know if it is a bug or if i did something wrong): If you restart the server, the attribute triggerExecutionSubentry in the=20 subentry gets lost... [10:52:14] WARN=20 [org.apache.directory.server.core.trigger.TriggerSpecCache] - Found=20 triggerExecutionSubentry 'cn=3Dtrigger,dc=3Dds,dc=3Dtest,dc=3Dnet' withou= t any=20 prescriptiveTriggerSpecification This is what i found out (without warranty, comments/imporovements welcom= e).=20 Maybe it helps a little bit. Approach: 1 Implementing Stored Procedure 2 Adding entry for Stored Procedure 3 Adding the trigger as Attritbute (trigger for one Entry only) 4 Or adding Triggers for more Entries, e.g. (Sub)-Tree 5 Activate and deactivate Triggers More docs: http://joacim.breiler.com/apacheds/ch09s02.html#Planned%20New%20Features%= 20for%20Triggers http://people.apache.org/~ersiner/ldapcon.2007/LDAPcon.2007_LDAP.Stored.P= rocedures.and.Triggers.in.ApacheDS_by.Ersin.Er_Paper.pdf 1 Implementing the Stored Procedure Stored Prodedure are simple POJO with one or more public static methods=20 (later called by the trigger). Example: package com.test; import java.util.ArrayList; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.entry.Modification; public class TestTriggerInterceptor { public static void helloTrigger(Entry oldEntry, ArrayList=20 mods ) { System.out.println("Entry found: " + oldEntry.getDn()); for (Modification modification : mods) { System.out.println(modification.getOperation() + " " + modification.getAttribute()); } } } 2 Adding Stored Procedures Adding a new ou for triggers, for example: ou=3DStored Procedures,ou=3Dsy= stem Adding a new entry (=3DStoredProcedure) for saving the StoredProcedure=20 (ObjectClass javaStoredProcUnit) Example: DN: storedProcUnitName=3Dcom.test.TestTriggerInterceptor,ou=3DStored=20 Procedures,ou=3Dsystem Definition LDAP Stored Procedure: =E2=80=A2 ObjectClass: javaStoredProcUnit and storedProcUnit =E2=80=A2 storedProcUnitName: complete classname, e.g.=20 com.test.TestTriggerInterceptor =E2=80=A2 storedProcLangId: always =E2= =80=9CJava=E2=80=9D =E2=80=A2 javaByteCode: Upload byte-code with ds-studio (the .class - = File) 3 Adding the trigger as Attritbute for one Entry only: Adding the attribut entryTriggerSpecification in the entry. The Value of the Attribute entryTriggerSpecification is the trigger,=20 example: AFTER Modify CALL "com.test.TestTriggerInterceptor:helloTrigger" ($oldEnt= ry,=20 $modification); --> helloTrigger is the public static Method, we implemented above Possible Triggers: =E2=80=A2 AFTER Modify CALL =E2=80=A2 AFTER Add CALL =E2=80=A6 =E2=80=A2 AFTER Delete CALL =E2=80=A6 =E2=80=A2 AFTER ModifyDN CALL =E2=80=A6 Some possible parameters for the trigger: (found in org.apache.directory.api.ldap.trigger.StoredProcedureParameter)= : Modify_OBJECT( "$object" ) Modify_MODIFICATION( "$modification" ) Modify_OLD_ENTRY( "$oldEntry" ) Modify_NEW_ENTRY( "$newEntry" ) Add_ENTRY( "$entry" ) Add_ATTRIBUTES( "$attributes" ) Delete_NAME( "$name" ) Delete_DELETED_ENTRY( "$deletedEntry" ) ModifyDN_ENTRY( "$entry" ) ModifyDN_NEW_RDN( "$newrdn" ) ModifyDN_DELETE_OLD_RDN( "$deleteoldrdn" ) ModifyDN_NEW_SUPERIOR(=20 "$newSuperior" ) ModifyDN_OLD_RDN( "$oldRDN" ) ModifyDN_OLD_SUPERIOR_DN(=20 "$oldRDN" ) ModifyDN_NEW_DN( "$oldRDN" ) Examples for static mehtods and trigger attribute entryTriggerSpecificati= on: Static method: public static void changeTrigger(Entry entry,=20 ArrayList mods ) { =E2=80=A6 } Trigger: AFTER Modify CALL "com.test.TriggerInterceptor:changeTrigg= er"=20 ($oldEntry, $modification); Static method: public static void addTrigger(Dn newEntryDn, Entry addEntr= y )=20 { =E2=80=A6 } Trigger: AFTER Add CALL "com.test.TriggerInterceptor:addTrigger"=20 ($entry, $attributes ); Static method: public static void deleteTrigger(Entry deleteEntry) { =E2=80= =A6 } Trigger: AFTER Delete CALL "=20 com.test.TriggerInterceptor:deleteTrigger" ($deletedEntry); 4 Adding Triggers for more Entries, e.g. (Sub)-Tree First: Adding an Administrative Area for Triggers --> adding new attribute administrativeRole with the Value --> triggerExecutionSpecificArea (didn't tries --> triggerExecutionInnerArea, don't what this is for) Then: adding a trigger-subentry (objectClass: triggerExecutionSubentry a= nd=20 subentry) Then: adding a prescriptiveTriggerSpecification attribute to the subentr= y. The value for prescriptiveTriggerSpecification is again the trigger, for= =20 Example: AFTER Modify CALL "com.test.TriggerInterceptor:changeTrigger" ($oldEntry,= =20 $modification); This approach does not work any more for me. When i restart my server, i = can=20 see the following log-Entry, when the server restarts: [10:52:14] WARN=20 [org.apache.directory.server.core.trigger.TriggerSpecCache] - Found=20 triggerExecutionSubentry 'cn=3Dtrigger,dc=3Dds,dc=3Dtest,dc=3Dnet' withou= t any=20 prescriptiveTriggerSpecification --> the subentry has definitely the attribute=20 prescriptiveTriggerSpecification, i don't know how to solve ... 5 Activate and deactivate Triggers Setting the attribut ads-enabled to TRUE/FALSE: DN:=20 ads-interceptorId=3DtriggerInterceptor,ou=3Dinterceptors,ads-directorySer= viceId=3Ddefault,ou=3Dconfig Emmanuel L=C3=A9charny schrieb am 9:35 Freitag,= =20 3.Februar 2017: Le 03/02/2017 =C3=A0 09:14, Jim Willeke a =C3=A9crit : > BTW: eDirectory has had LDAP Event Services which allows a client or a > server process to register for events and take an action. > > https://www.novell.com/documentation/developer/ldapover/ldap_enu/data/ > ag7bleo.html It's a slightly different system, AFAIU. events are sent to the client fo= r=20 it to act. In ApacheDS, it's really a way to configure the server to do=20 something when a specific update occurs. --=20 Emmanuel Lecharny Symas.com directory.apache.org