lmldap reference

Complete server and host CLI flag reference, integrated HTTP REST API endpoints, host schema types and methods (Ldap, Batch), standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lmldap v0.1.0.

Server and host CLI flags

Flag or environment variableArguments / defaultDescription
--version / -vnonePrint the lmldap version string (lmldap 0.1.0) and exit 0.
--lmcode-schema[--json]Print the embedded schema/lmldap.dsl.json definition to stdout and exit 0.
--lmcode-signaturesnonePrint all 244 canonical context, function, and method signatures (18 host + 226 standard library) and exit 0.
--lmcode<file.dslb>Load and execute a compiled LMScript bytecode program against the embedded lmldap schema.
--port<int> (default 389)TCP port for the native RFC 4511 LDAPv3 listener (binds 0.0.0.0:<port> in zero-config mode).
--rest-port<int> (default 0 / disabled)TCP port for the integrated HTTP/JSON REST server bridge.
--base-dn<dn> (default dc=example,dc=com)Directory base Distinguished Name auto-provisioned in slapd.conf and seeded on startup.
--admin-dn<dn> (default cn=admin,<base-dn>)Root/administrator Distinguished Name granted write permissions in slapd.conf.
--admin-pw<password> (default secret)Root/administrator password used by slapd and the integrated REST bridge.
--data-dir<path> (default /tmp/lmldap-data-<port>)Directory path for auto-generated slapd.conf, schema.conf, slapd.pid, and mdb/ database files.
--daemonizeyes | no | 1 | true (default false)Allow slapd to detach into the background instead of running in foreground mode (-d 0).
-f / -F / -h / -dupstream slapd argumentsPass explicit slapd configuration file (-f), config directory (-F), listener URLs (-h), or debug level (-d).
LDAP_HOST / LDAP_PORTenv vars (default 127.0.0.1 / 389)Override target LDAPv3 host and port used by context ldap: Ldap during _lmcode_ execution.
LDAP_BIND_DN / LDAP_BIND_PWenv vars (default cn=admin,dc=example,dc=com / secret)Override simple bind credentials used by context ldap: Ldap during _lmcode_ execution.

Integrated HTTP REST API endpoints (--rest-port)

HTTP methodPath and queryResponse format and behavior
GET/ or /healthReturn 200 JSON {"ok":true,"service":"lmldap","version":"0.1.0","base_dn":"...","result":"PONG"}.
GET/pingReturn 200 JSON {"ok":true,"result":"PONG"}.
GET/search?base=<dn>&filter=<f>&scope=sub|one|base (or /entries)Search directory entries and return 200 JSON {"ok":true,"result":[{"dn":"...","attributes":{...}}]}.
GET/entry/<dn>Fetch a single entry by URL-encoded DN as {"ok":true,"result":{"dn":"...","attributes":{...}}} or 404 if missing.
PUT/entry/<dn>Create or replace an entry from a JSON object of attribute values and return {"ok":true,"result":"OK"}.
POST/entry/<dn>Modify attributes on an existing entry (or create if absent) from a JSON object and return {"ok":true,"result":"OK"}.
DELETE/entry/<dn>Delete an entry by DN and return {"ok":true,"result":1} (or 0 if the entry did not exist).
POST/bindVerify credentials from JSON {"dn":"...","password":"..."} and return 200 {"ok":true,"result":{"bound":true,"dn":"..."}} or 401.

Host schema types, methods, and functions

Type / contextSignatureDescription
context ldap: Ldapldap.add(dn: string, attrs_json: string) -> boolCreate or replace a directory entry at dn from a JSON object of attributes.
Ldapldap.get(dn: string) -> stringFetch a single directory entry by dn as a JSON string ({"dn":...,"attributes":{...}}), or "" if not found.
Ldapldap.search(base_dn: string, filter: string) -> stringRun a subtree search under base_dn with an RFC 4515 filter and return a JSON array string of matching entries.
Ldapldap.modify(dn: string, mods_json: string) -> boolModify or replace attributes on dn from a JSON object of attribute values.
Ldapldap.del(dn: string) -> intDelete the entry at dn and return 1 if deleted or 0 if not found.
Ldapldap.exists(dn: string) -> boolReturn true if an entry exists at dn, or false otherwise.
Ldapldap.bind(dn: string, password: string) -> boolVerify simple bind credentials for dn and password against the live server or fallback store.
Ldapldap.batch() -> BatchCreate a new Batch builder for queued directory operations.
Batchb.add(dn: string, attrs_json: string) -> BatchQueue an ADD operation on the batch and return the Batch for chaining.
Batchb.get(dn: string) -> BatchQueue a GET operation by dn on the batch.
Batchb.search(base_dn: string) -> Batch | b.search(base_dn: string, filter: string) -> BatchQueue a subtree SEARCH operation with default (objectClass=*) or explicit filter.
Batchb.modify(dn: string, mods_json: string) -> BatchQueue a MODIFY operation on the batch.
Batchb.del(dn: string) -> BatchQueue a DEL operation by dn on the batch.
Batchb.len() -> int | b.clear() -> voidReturn the number of queued operations in the batch or clear all queued operations.
Batchb.exec() -> stringExecute all queued operations in order and return a JSON array string of results.
global functionprint(msg: string) -> voidWrite a string followed by a newline to stdout.

Standard lmcode_std_v3 REST and CLI interfaces

Interface or functionSignature / annotationDescription
RestGet .. RestOptions@"/path/:param" fn h(x: RestExchange) -> void implements RestGetBind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler.
RestHandler@"/path" fn h(x: RestExchange) -> void implements RestHandlerBind a method-agnostic HTTP route handler.
CliCommand@"cmd" fn h(x: RestExchange) -> void implements CliCommandBind a named CLI subcommand dispatched by rest_cli.
CliOption@"--flag" fn h(x: RestExchange) -> void implements CliOptionBind a CLI option flag (--flag=val or --flag val) evaluated before the command handler.
rest_config / rest_routerest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> voidConfigure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers.
rest_serve / rest_stop / rest_clirest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> stringStart or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process.
RestExchangex.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) | x.get(string) -> string | x.has_query(string) | x.has_header(string) -> bool | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) | x.set(string, string) -> void | x.increment(string) -> intInspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state.

Exit codes

Exit codeCategoryMeaning
0SuccessServer exited cleanly, metadata flag printed, or _lmcode_ program completed with LMCODE_RETURN ok:true.
1Server errorOpenLDAP slapd failed to initialize configuration, LMDB storage, or listener sockets.
2Usage errorMissing --lmcode <file> argument in host execution mode (phase cli, code CLI_USAGE).
3Host / VM errorBytecode load failure (phase load) or runtime execution/assertion error (phase run) during _lmcode_ execution.