ldap.reader

function

Library: LDAP support (OMLDAP)
Import : omldap.xmd

Returns: The value of a specified attribute.


Declaration
define external stream function ldap.reader
    of       value ldap.attribute attribute
    item     value integer        index      optional
    null     value string         null       optional
    using    value integer        datatype   optional

Argument definitions

attribute
An ldap.attribute containing the current entry.
item
The position number of the requested item. The default is 1.
null
A string to represent a NULL value for the return value. (This could be set to "NO VALUE", for example.) The default is "".
datatype
The type of the requested attribute value. The default is ldap.text-type; the other option is ldap.binary-type.


Purpose

This function returns the value of a specified attribute. If an index is not specified, it returns the first value, otherwise it returns the specified one.

The following example outputs the telephone number for each entry satisfying the search. Each entry is assumed to have a single telephone number.

  import "omldap.xmd" prefixed by ldap.
  
  process
     local ldap.connection my-ldap
     local ldap.attribute  my-entry variable
  
     set my-ldap to ldap.open 'www.stilo.com'
     ldap.search my-ldap
        base  "o=stilo.com"
        where  "(Department=RD)"
        into   my-entry
        select "phonenumber"
  
     repeat
        exit unless ldap.entry-exists my-entry
        output ldap.entry-name of my-entry || ": "
            || ldap.reader of my-entry{"phonenumber"}
            || "%n"
        ldap.advance-entry my-entry
     again

ldap.retrieve-values can be used when an attribute contains an unknown number of values.