ldap

Implementation of the Light Weight Directory Access Protocol
exception Server_error of string

raised whenever an error occurrs in the server

type connection_id = int
type backendInfo = {
bi_op_bind : ( connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message ) option;
bi_op_unbind : ( connection_id -> Ldap_types.ldap_message -> unit ) option;
bi_op_compare : ( connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message ) option;
bi_op_modify : ( connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message ) option;
bi_op_modrdn : ( connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message ) option;
bi_op_add : ( connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message ) option;
bi_op_delete : ( connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message ) option;
bi_op_abandon : ( connection_id -> Ldap_types.ldap_message -> unit ) option;
bi_op_extended : ( connection_id -> Ldap_types.ldap_message -> Ldap_types.ldap_message ) option;
bi_init : ( unit -> unit ) option;
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 = [
| `GENERAL
| `CONNECTION
| `OPERATIONS
| `ERROR
| `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.