Przykłady

Test połączenia z serwerem:

$ldap.checkAuthorization("ldap://111.222.111.222:389", "cn=Directory Manager", "password")
Odczytanie atrybutów i ich wartości dla podanego węzła, pokazane zostaną  tylko te atrybuty których identyfikator jest równy "state", czyli pole zawierające stan usługi tv, klienta testowicz, w regionie first-region, dla podanego ret1:

$for(@item, 
  (List)$ldap.getAttributes("ldap-services", "serviceName=tv,uniqueID=testowicz,ou=first-region,retailername=ret1,o=Users,o=UMC", ["state"])
, {
  $@item
})
Ustawienie atrybutów w węźle, w trybie REPLACE_ATTRIBUTE (zostaną nadpisane o ile istnieją), klientowi joe zostaną nadane dwa imiona, oraz trzy pojedyncze pola:

$ldap.modifyAttributes("ldap-vas", "uniqueID=joe,ou=first-region,retailername=virtual-SP,o=Users,o=UMC", 2, [
 ["sn", "sn2"],
 ["cn", "cn2"],
 ["givenName", "n2"],
 ["givenName", "n3"],
 ["userPassword", null]
])
Kod groovy, pobierający kontekst dostawcy, a następnie wyszukujący określony region:

LdapContext ctx = ldap.lookup("ldap-test", "retailername=virtual-SP,o=Users,o=UMC")

Attributes sAttrs = new BasicAttributes(true);  
sAttrs.put(new BasicAttribute("ou", "first-region"));  

NamingEnumeration list = ctx.search("", sAttrs);
while (list.hasMore()) {
    SearchResult sr = (SearchResult)list.next();
    System.out.println(sr.getAttributes());
}
Dodawanie elementu drzewa (określający użytkownika):

Attribute atr;
Attributes matchAttrs = new BasicAttributes(true);  
matchAttrs.put(new BasicAttribute("cn", "tmpUser cn"));             
matchAttrs.put(new BasicAttribute("sn", "tmpUser sn"));        
matchAttrs.put(new BasicAttribute("givenName", "tmpUser gn"));             
matchAttrs.put(new BasicAttribute("userPassword", ""));
atr = new BasicAttribute("objectClass");
atr.add("top");
atr.add("person");
atr.add("organizationalPerson");
atr.add("inetOrgPerson");
atr.add("umcUser");
atr.add("umcSubscriber");
matchAttrs.put(atr);    

ldap.bind("ldap-vas", "uniqueID=tmpUser,ou=first-region,retailername=virtual-SP,o=Users,o=UMC", (Attributes)matchAttrs)