ldapSearch

function

Library: LDAP support (OMLDAP legacy)
Include: omldap.xin

Declaration
define external function ldapSearch
             value      ldapConnection connection
     base    value      stream         base
     scope   value      integer        scope      optional  initial { LDAP_SCOPE_ONELEVEL }
     where   value      stream         filter
     entry   modifiable ldapAttribute  entry
     format  value      integer        format     optional  initial { LDAP_FORMAT_VALUE }
     selects read-only  stream         attributes optional
     select  remainder  stream         attribute

Where:

Argument definitions

connection
A connection to an LDAP server.
base
The root value for the start of the search.
scope
A parameter that specifies how deep in the tree you want to search. The default is LDAP_SCOPE_ONELEVEL. The other possible parameters are LDAP_SCOPE_BASE and LDAP_SCOPE_SUBTREE.
filter
The search filter for this scope.
entry
A shelf of ldapAttribute items bound to the result.
format
The format of the search result. LDAP_FORMAT_VALUE is the default; the other value is LDAP_FORMAT_VALUE_TYPE.
attributes
A shelf of attribute names whose values you want returned.
attribute
An attribute name whose value you want returned. Since this parameter is a remainder, more than one attribute name may be listed.


Purpose

The ldapSearch function executes a search on the LDAP server specified by ldapConnection.

The following example searches one level deep from the base of "omnimark.com" in the RD department for the name, employee number, and phone number of whatever entry my-entry has been set to.

      include "omldap.xin"
  
      process
         local ldapAttribute my-entry variable
         ...
         ldapSearch my-ldap
            base "o=omnimark.com"
            scope LDAP_SCOPE_ONELEVEL
            where"(Department=RD)"
            entry my-entry
         	  select "name"
         	  select "employeenumber"
         	  select "phonenumber"

These lines are part of a larger program that repeats over my-entry so that the information for all the employees in department RD is found and output.