package ldap

  1. Overview
  2. Docs

A functional ldap server construction kit

exception Server_error of string

raised whenever an error occurrs in the server

type connection_id = int
type backendInfo = {
  1. bi_op_bind : (connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message) option;
  2. bi_op_unbind : (connection_id -> Ldap_types.ldap_message -> unit) option;
  3. bi_op_compare : (connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message) option;
  4. bi_op_modify : (connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message) option;
  5. bi_op_modrdn : (connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message) option;
  6. bi_op_add : (connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message) option;
  7. bi_op_delete : (connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message) option;
  8. bi_op_abandon : (connection_id -> Ldap_types.ldap_message -> unit) option;
  9. bi_op_extended : (connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message) option;
  10. bi_init : (unit -> unit) option;
  11. bi_close : (unit -> unit) option;
}

This structure is the guts of the ldap server. For each operation that you implement put the function (or closure) of the correct type in this structure. Any functions you set as None will return `UNWILLING_TO_PERFORM, with the error string set to "not implemented". bi_init will be called (if it is provided) before the server is brought up, and bi_close (if it is provided) will be called before the server is brought down. This interface is based loosely on the back-end api in OpenLDAP.

type log_level = [
  1. | `GENERAL
  2. | `CONNECTION
  3. | `OPERATIONS
  4. | `ERROR
  5. | `TRACE
]

This abstract type contains the server context. It has the listening, socket, all the connected client sockets, and some internal data structures.

type server_info
val init : ?log:(log_level -> string -> unit) -> ?port:int -> backendInfo -> server_info

Initialize the server, create the listening socket and return the server context, which you will pass to serv to process connections. log is a string -> log_level -> unit function to which log messages will be sent.

val shutdown : server_info -> unit

Shutdown the server

val run : server_info -> unit

Using the supplied server context, begin processing ldap operations. This function should never terminate unless there is an exceptional condition, in which case the exception will be raised. In many cases it is safe to restart the server process when an exception happens.

OCaml

Innovation. Community. Security.