JNDI Examples

Performing and LDAP Search

The following example shows how to query for and iterate over a set of LDAP entries using a for each statement with a where clause.

The condition restricts the query to participants named 'Robert' belonging to the 'Documentation' Organizational Unit.
  for each hp in humanparticipant
      where hp.ou = "Documentation" and hp.cn = "Robert" do
     display "The participant: " + hp.cn
  end

Searching LDAP by DN

To retrieve a directory entry by its dn (Distinguished Name), you should use the lookup() method instead of the for each statement.
 myDN = "c=Argentina"
 result = lookup(country, dn : myDN)

 if (result) then
    delete country
 end

Add new LDAP entry

This example shows how to add a new entry to the directory.
 o1 = OrganizationalUnit()
 o1.ou = "test21"
 o1.description = "foo1"
 o1.dn = "ou=test21"
 o1.postalCode = "1001"
 o1.store()