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 variable | Arguments / default | Description |
|---|---|---|
| --version / -v | none | Print 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-signatures | none | Print 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. |
| --daemonize | yes | no | 1 | true (default false) | Allow slapd to detach into the background instead of running in foreground mode (-d 0). |
| -f / -F / -h / -d | upstream slapd arguments | Pass explicit slapd configuration file (-f), config directory (-F), listener URLs (-h), or debug level (-d). |
| LDAP_HOST / LDAP_PORT | env 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_PW | env 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 method | Path and query | Response format and behavior |
|---|---|---|
| GET | / or /health | Return 200 JSON {"ok":true,"service":"lmldap","version":"0.1.0","base_dn":"...","result":"PONG"}. |
| GET | /ping | Return 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 | /bind | Verify credentials from JSON {"dn":"...","password":"..."} and return 200 {"ok":true,"result":{"bound":true,"dn":"..."}} or 401. |
Host schema types, methods, and functions
| Type / context | Signature | Description |
|---|---|---|
| context ldap: Ldap | ldap.add(dn: string, attrs_json: string) -> bool | Create or replace a directory entry at dn from a JSON object of attributes. |
| Ldap | ldap.get(dn: string) -> string | Fetch a single directory entry by dn as a JSON string ({"dn":...,"attributes":{...}}), or "" if not found. |
| Ldap | ldap.search(base_dn: string, filter: string) -> string | Run a subtree search under base_dn with an RFC 4515 filter and return a JSON array string of matching entries. |
| Ldap | ldap.modify(dn: string, mods_json: string) -> bool | Modify or replace attributes on dn from a JSON object of attribute values. |
| Ldap | ldap.del(dn: string) -> int | Delete the entry at dn and return 1 if deleted or 0 if not found. |
| Ldap | ldap.exists(dn: string) -> bool | Return true if an entry exists at dn, or false otherwise. |
| Ldap | ldap.bind(dn: string, password: string) -> bool | Verify simple bind credentials for dn and password against the live server or fallback store. |
| Ldap | ldap.batch() -> Batch | Create a new Batch builder for queued directory operations. |
| Batch | b.add(dn: string, attrs_json: string) -> Batch | Queue an ADD operation on the batch and return the Batch for chaining. |
| Batch | b.get(dn: string) -> Batch | Queue a GET operation by dn on the batch. |
| Batch | b.search(base_dn: string) -> Batch | b.search(base_dn: string, filter: string) -> Batch | Queue a subtree SEARCH operation with default (objectClass=*) or explicit filter. |
| Batch | b.modify(dn: string, mods_json: string) -> Batch | Queue a MODIFY operation on the batch. |
| Batch | b.del(dn: string) -> Batch | Queue a DEL operation by dn on the batch. |
| Batch | b.len() -> int | b.clear() -> void | Return the number of queued operations in the batch or clear all queued operations. |
| Batch | b.exec() -> string | Execute all queued operations in order and return a JSON array string of results. |
| global function | print(msg: string) -> void | Write a string followed by a newline to stdout. |
Standard lmcode_std_v3 REST and CLI interfaces
| Interface or function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config / rest_route | rest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> void | Configure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers. |
| rest_serve / rest_stop / rest_cli | rest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> string | Start or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process. |
| RestExchange | x.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) -> int | Inspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | Server exited cleanly, metadata flag printed, or _lmcode_ program completed with LMCODE_RETURN ok:true. |
| 1 | Server error | OpenLDAP slapd failed to initialize configuration, LMDB storage, or listener sockets. |
| 2 | Usage error | Missing --lmcode <file> argument in host execution mode (phase cli, code CLI_USAGE). |
| 3 | Host / VM error | Bytecode load failure (phase load) or runtime execution/assertion error (phase run) during _lmcode_ execution. |