Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 57534E8C4 for ; Wed, 28 Nov 2012 16:48:39 +0000 (UTC) Received: (qmail 94659 invoked by uid 500); 28 Nov 2012 16:48:39 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 94620 invoked by uid 500); 28 Nov 2012 16:48:39 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 94609 invoked by uid 99); 28 Nov 2012 16:48:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2012 16:48:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Nov 2012 16:48:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9F86F2388A40 for ; Wed, 28 Nov 2012 16:48:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r839907 - in /websites/staging/directory/trunk/content: ./ apacheds/advanced-ug/ api/ api/groovy-api/ Date: Wed, 28 Nov 2012 16:48:10 -0000 To: commits@directory.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121128164810.9F86F2388A40@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: buildbot Date: Wed Nov 28 16:48:09 2012 New Revision: 839907 Log: Staging update by buildbot for directory Added: websites/staging/directory/trunk/content/api/groovy-api/4-groovy-ldap-building.html websites/staging/directory/trunk/content/api/groovy-api/5-groovy-ldap-reference.html websites/staging/directory/trunk/content/api/groovy-api/6-groovy-ldap-origin.html Removed: websites/staging/directory/trunk/content/api/groovy-api/4-groovy-ldap-build.html websites/staging/directory/trunk/content/api/groovy-ldap-origin.html Modified: websites/staging/directory/trunk/content/ (props changed) websites/staging/directory/trunk/content/apacheds/advanced-ug/1.5-schemamanager.html Propchange: websites/staging/directory/trunk/content/ ------------------------------------------------------------------------------ --- cms:source-revision (original) +++ cms:source-revision Wed Nov 28 16:48:09 2012 @@ -1 +1 @@ -1414787 +1414807 Modified: websites/staging/directory/trunk/content/apacheds/advanced-ug/1.5-schemamanager.html ============================================================================== --- websites/staging/directory/trunk/content/apacheds/advanced-ug/1.5-schemamanager.html (original) +++ websites/staging/directory/trunk/content/apacheds/advanced-ug/1.5-schemamanager.html Wed Nov 28 16:48:09 2012 @@ -118,7 +118,7 @@
@@ -142,7 +142,7 @@
Added: websites/staging/directory/trunk/content/api/groovy-api/4-groovy-ldap-building.html ============================================================================== --- websites/staging/directory/trunk/content/api/groovy-api/4-groovy-ldap-building.html (added) +++ websites/staging/directory/trunk/content/api/groovy-api/4-groovy-ldap-building.html Wed Nov 28 16:48:09 2012 @@ -0,0 +1,209 @@ + + + + + 4 - Groovy LDAP : Buildng the Software — Apache Directory + + + + + + +
+ +
+
+ + + +
+
+ + + + + +

4 - Groovy LDAP : Buildng the Software

+

Building the software

+

Resolving the dependencies

+

Groovy LDAP needs Java 5 to compile. Besides this, it has only one dependency: Groovy itself. For LDAP communication, JNDI and its LDAP provider are used. These are part of the JDK since ages.

+

In order to build the software, Apache ant is used. For dependency resolution we use Ivy. You need to configure your ant tool to use Ivy. One option is to place the corresponding jar file ivy-1.4.1.jar (or later) in the lib folder of your ant distribution.

+

Building with ant and ivy (deprecated)

+

Simply change to the groovyldap directory and type ant.

+
D:\Apache>cd groovyldap
+D:\Apache\groovyldap>ant
+Buildfile: build.xml
+
+prepare:
+    [mkdir] Created dir: D:\Apache\groovyldap\dist
+    [mkdir] Created dir: D:\Apache\groovyldap\dist\classes
+    [mkdir] Created dir: D:\Apache\groovyldap\lib
+
+resolve:
+[ivy:retrieve] :: Ivy 1.4.1 - 20061109165313 :: http://ivy.jayasoft.org/ ::
+
+...
+
+jarfile:
+      [jar] Building jar: D:\Apache\groovyldap\dist\groovy-ldap.jar
+
+BUILD SUCCESSFUL
+Total time: 7 seconds
+D:\Apache\groovyldap>_
+
+ + +

Done.

+

The jarfile which includes the software, groovy-ldap.jar, is created in the dist directory. Feel free to call ant clean afterwards.

+

Building with Maven

+

We are changing the build process to Maven 2, in order to have the same build tool for all sub projects within Apache Directory.

+

Simply change to the groovyldap directory and type mvn install.

+
D:\Apache\groovyldap>mvn install
+[INFO] Scanning for projects...
+[INFO] -----------------------------------------------------------------
+[INFO] Building Apache Directory Groovy LDAP
+[INFO]    task-segment: [install]
+[INFO] -----------------------------------------------------------------
+...
+[INFO] -----------------------------------------------------------------
+[INFO] BUILD SUCCESSFUL
+[INFO] -----------------------------------------------------------------
+[INFO] Total time: 25 seconds
+[INFO] Finished at: Mon Mar 02 22:06:54 CET 2009
+[INFO] Final Memory: 19M/38M
+[INFO] -----------------------------------------------------------------
+
+ + + + + +
+
+
+ +
+ + \ No newline at end of file Added: websites/staging/directory/trunk/content/api/groovy-api/5-groovy-ldap-reference.html ============================================================================== --- websites/staging/directory/trunk/content/api/groovy-api/5-groovy-ldap-reference.html (added) +++ websites/staging/directory/trunk/content/api/groovy-api/5-groovy-ldap-reference.html Wed Nov 28 16:48:09 2012 @@ -0,0 +1,283 @@ + + + + + 5 - Groovy LDAP Reference — Apache Directory + + + + + + +
+ +
+
+ + + +
+
+ + + + + +

5 - Groovy LDAP Reference

+ + + +

The search method performs an LDAP search operation and returns the result as a list of entries. In Groovy LDAP, an entry is simply a map.

+

Three options to call a search method

+

Short cut methods

+

For the most common types of search requests, the LDAP class contains two direct methods.

+
public List<Object> search( String filter ) throws NamingException
+public List<Object> search( String filter, String base, SearchScope scope ) throws NamingException
+
+ + +

This example uses the second variant:

+
...
+ldap = LDAP.newInstance('ldap://zanzibar:10389/')
+
+results = ldap.search('(objectClass=person)', 'dc=example,dc=com', SearchScope.ONE)
+println " ${results.size} entries found ".center(40,'-')
+for (entry in results) {
+  println entry.dn
+}
+...
+
+ + +

Using a Search object

+

The class org.apache.directory.groovyldap.Search is a JavaBean which contains parameters for a search.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Property nameTypeDefault valueDescription
basejava.lang.String""Search base
scopeorg.apache.directory.groovyldap.SearchScopeSearchScope.SUB (whole sub tree)Search scope, one of BASE, ONE, SUB
filterjava.lang.String"(objectClass=*)" (matches all entries)filter expression
filterArgsjava.lang.Object[]nullfilter arguments
attrsjava.lang.String[]null (all attributes)returning attributes
+

You can simply create an object of this class, adjust the attributes to your needs and call an appropriate search method from the LDAP class with it. Here is an example:

+
...
+params = new Search()
+params.filter='(objectClass=person)'
+params.base='dc=example,dc=com'
+params.scope=SearchScope.ONE
+
+results = ldap.search(params)
+...
+
+ + +

Using map style syntax

+

A very handy way to call search operations is to use the expressive map style arguments. The same properties as described for the Search class are supported. Here is an example.

+
...
+results = ldap.search(filter: '(objectClass=person)', 
+    base: 'dc=example,dc=com', scope: 'ONE')
+...
+
+ + +

The order of arguments does not matter, and this variant is very descriptive, and therefore recommended to use.

+

Using filter arguments

+

JNDI supports filter expressions with placeholders like {0}, {1} etc., and Groovy LDAP offers their use as well. +Here is a simple example:

+
...
+params = new Search()
+params.filter='(&(objectClass={0})(cn={1}))'
+params.filterArgs=['person', 'Heather Nova']
+
+results = ldap.search(params)
+...
+
+ + +

It is possible to use this in map style as well.

+ +

tbd.

+ + + + + +
+
+
+ +
+ + \ No newline at end of file Added: websites/staging/directory/trunk/content/api/groovy-api/6-groovy-ldap-origin.html ============================================================================== --- websites/staging/directory/trunk/content/api/groovy-api/6-groovy-ldap-origin.html (added) +++ websites/staging/directory/trunk/content/api/groovy-api/6-groovy-ldap-origin.html Wed Nov 28 16:48:09 2012 @@ -0,0 +1,164 @@ + + + + + 6 - Groovy LDAP Origin — Apache Directory + + + + + + +
+ +
+
+ + + +
+
+ + + + + +

6-Groovy LDAP Origin

+

I did some research about accessing LDAP from Groovy, in order to create some simple scripts. It is possible to use both JNDI and libraries like Netscape or Novell SDK from Groovy (you can basically use any Java library in Groovy scripts).

+

But these approaches have disadvantages. Netscape SDK is plain LDAP, so the scripts look like one familiar to LDAP would expect. But the API is not connected very well to the Collection API, so sometimes it is not easy to use the result from Groovy. And you have a non-standard dependency. JNDI on the other hand is easier to use (exists in every VM), but the scripts look horrible, because of the LDAP abstraction JNDI does. For instance you have to type "entry.nameInNamespace" instead of "entry.DN" (Netscape).

+

It seems that there does no special solution/library for Groovy and LDAP exist. So I started to create a little prototype. Basically, it is a wrapper which uses JNDI (in order to omit the dependency to a non-standard library) under the hood, but looks like LDAP from the outside (script). Unfortunately, I am not a Groovy expert.

+

Stefan Zoerner on Jun 30, 2007

+ + + + + +
+
+
+ +
+ + \ No newline at end of file