Hi all!
Just for your information, if you are interested in Groovy (if not, stop
reading):
I have started a prototype for an LDAP integration in Groovy, as I have
mailed last week (perhaps a binding, still not sure, what this word
exactly means ;-) ).
Anyway, Dierk König (author from "Groovy in Action") has commented my
integration efforts. I tried to include some of his ideas within my
little prototype. It looks more like Groovy now, which was the plan. For
instance, although functionality is still quite limited, you can already
use closures in searches now:
---
import org.apache.directory.groovyldap.LDAP
ldap = LDAP.newInstance('ldap://zanzibar:10389/dc=example,dc=com')
ldap.eachEntry ('(objectClass=person)') { person ->
println "${person.cn} (${person.dn})"
}
---
A sample output of this script:
Tori Amos (cn=Tori Amos,dc=example,dc=com)
Kate Bush (cn=Kate Bush,dc=example,dc=com)
Heather Nova (cn=Heather Nova,dc=example,dc=com)
I still allow "classic" LDAP searches by the way, in order to make it
easier for those not familiar with Groovy (me, for instance)
---
import org.apache.directory.groovyldap.*
ldap = LDAP.newInstance('ldap://zanzibar:10389/')
results = ldap.search('(objectClass=*)', 'dc=example,dc=com',
SearchScope.ONE)
println " ${results.size} entries found ".center(40,'-')
for (entry in results) {
println entry.dn
}
---
Sample output:
----------- 3 entries found ------------
cn=Tori Amos,dc=example,dc=com
cn=Kate Bush,dc=example,dc=com
cn=Heather Nova,dc=example,dc=com
Learn more about my latest additions to the prototype here
http://cwiki.apache.org/confluence/display/DIRxSBOX/Groovy+LDAP
I have posted to the Groovy users list, in order to get some feedback
from them as well ...
Greetings from Hamburg,
Stefan
--- Begin Message ---
Hi all!
I did some research about accessing LDAP from Groovy, mainly in order to
create some simple scripts. We at the Directory project also think about
providing the option to program stored procedures and triggers within
our LDAP server (ApacheDS) in Groovy. But my current focus are
administrators, who plan to write scripts to perform daily work tasks
without the need of Java/JNDI programming etc.
This is what I got so far: It is possible to use both JNDI and libraries
like Netscape or Novell SDK from Groovy, but none of them integrates
very well in Groovy. For LDAP administrators, especially the JNDI API is
unacceptable, because the abstraction from LDAP has no benefit, and the
operations they know have other method names ("createContext" instead of
"add" to create an entry, for instance).
It seems that no special solution/library/module for Groovy and LDAP
exist yet. So I started to create a little prototype within the sandbox
of the Apache Directory Project. It already offers some functionality
(adding entries, search with closures, ...). Some information about it
is here:
http://cwiki.apache.org/confluence/display/DIRxSBOX/Groovy+LDAP
The page contains sample scripts, as well. Please note that I am not a
Groovy expert. Any feedback from you guys is therefore highly
appreciated. What do you think?
Dierk Koenig has commented a first version (Thanks again for that!), and
I have already tried to integrate his ideas in order to make the API
more Groovy'ish. He pointed out that there are efforts to include LDAP
support in Grails, but I would prefer a solution with a minimum number
of dependencies (especially no Spring/Spring LDAP, only Java SE and Groovy).
Greetings from Hamburg,
Stefan
---8<---
Stefan Zoerner ([EMAIL PROTECTED])
Committer :: PMC Member
Apache Directory Project
http://directory.apache.org
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
--- End Message ---