directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Zoerner <ste...@labeo.de>
Subject [Fwd: [groovy-user] Groovy and LDAP]
Date Sat, 23 Jun 2007 16:05:52 GMT
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

Mime
View raw message