1. Introduction
  2. Examples
    1. Getting an attribute of all objects
  3. Authors
  4. Requirements
  5. Parsing an LDIF file
  6. Generating an LDIF file
  7. License
  8. Version history

Introduction

Parser and generator for LDIF (LDAP Data Interchange Format) files.

The parser returns a stream of hashes, one for each entry in the file. Each hash has as keys names of attributes and as values lists of the values for the given keys.

The generator expects information in exactly the same format (which makes it easy to perform transformations in LDIF files, for example).

Examples

...

Getting an attribute of all objects

The following example prints all the values for the cn attributes for all objects in the LDIF file:

(use stream-ldif format-modular)

(stream-for-each
  (lambda (hash)
    (for-each
      (lambda (value)
        (format #t "~A~%" (stream->string value)))
      (hash-table-ref/default hash 'cn '())))
  (stream->ldif (port->stream (current-input-port))))

Authors

The stream-ldif egg was created by Alejandro Forero Cuervo.

Requirements

Parsing an LDIF file

(stream->ldif stream)

Given a stream of characters corresponding to a file in the LDIF format, returns a stream of hash tables. Each hash table corresponds to one of the entries in the LDIF file. The hash tables are indexed by the names of the attributes in lowercase (as symbols); each value is a list with all the values (as streams of characters).

The parsing of the LDIF stream is done in a lazy file, reading entries only as required (as the stream of hash table is built).

Generating an LDIF file

(ldif->stream stream)

Performs the opposite function of stream->ldif: given a stream with hashes corresponding to changes, produces an LDIF file and returns it as a stream of characters. Each hash should be indexed by the names of the attribute as symbols; the value for each entry must be a list with the values for the attributes as streams of characters encoded in UTF-8.

Note that each hash table must always contain a dn entry having its distinguished name as its first element.

License

The stream LDIF egg for Chicken Scheme is in the public domain and may be reproduced or copied without permission from its author. Citation of the source is appreciated.

Version history

1.1
Adapted to SRFI-69-compatible hash-tables
1.0
First public release