Path: redb-route/redb.Route.Ldap/README.md Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Ldap/README.md ---- # redb.Route.Ldap > Documentation and articles: LDAP / Active Directory connector for redb.Route. Search, CRUD, authentication, and change tracking — all directory operations as endpoints via Novell.Directory.Ldap.NETStandard. [![NuGet](https://img.shields.io/nuget/v/redb.Route.Ldap?label=NuGet&color=blue)](https://www.nuget.org/packages/redb.Route.Ldap) [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue)](../../LICENSE) ## Installation ```bash dotnet add package redb.Route.Ldap ``` ## Usage ### URI Format ``` ldap:OPERATION:baseDn?server=host&port=389&bindDn=cn=admin,dc=example,dc=com&bindPassword=secret ``` ### Fluent DSL ```csharp using redb.Route.Ldap; // Search users From(LdapDsl.Search("ou=users,dc=example,dc=com") .Server("ldap.example.com") .BindDn("cn=admin,dc=example,dc=com") .BindPassword("secret") .Filter("(objectClass=inetOrgPerson)") .Scope(LdapSearchScope.Subtree) .Attributes("cn", "mail", "uid") .PageSize(500)) .Log("Found: ${header['redbLdap.ResultCount']} entries") .To("direct://process"); // Watch for changes (consumer — polls for modifications) From(LdapDsl.Watch("ou=users,dc=example,dc=com") .Server("ldap.example.com") .BindDn("cn=admin,dc=example,dc=com") .BindPassword("secret") .ChangeTracking(LdapChangeTrackingMode.ModifyTimestamp) .PollInterval(5000) .InitialLoad()) .Log("Changed entry: ${body}") .To("direct://sync"); // Add entry From("direct://create-user") .To(LdapDsl.Add("ou=users,dc=example,dc=com") .Server("ldap.example.com") .BindDn("cn=admin,dc=example,dc=com") .BindPassword("secret")); // Modify entry From("direct://update-user") .To(LdapDsl.Modify("cn=alice,ou=users,dc=example,dc=com") .Server("ldap.example.com") .BindDn("cn=admin,dc=example,dc=com") .BindPassword("secret")); // Bind (authentication check) From("direct://authenticate") .To(LdapDsl.Bind("dc=example,dc=com") .Server("ldap.example.com")); ``` ## Fluent Builder API | Category | Methods | |----------|---------| | **Operations** | `LdapDsl.Search()`, `LdapDsl.Compare()`, `LdapDsl.Add()`, `LdapDsl.Modify()`, `LdapDsl.Delete()`, `Ldap.Rename()`, `LdapDsl.Bind()`, `LdapDsl.Watch()` | | **Connection** | `.Server()`, `.Port()`, `.Ssl()`, `.StartTls()`, `.ConnectionFactory()`, `.ConnectTimeout()`, `.OperationTimeout()` | | **Auth** | `.BindDn()`, `.BindPassword()` | | **Search** | `.Filter()`, `.Scope()`, `.Attributes()`, `.PageSize()`, `.SizeLimit()`, `.TimeLimit()` | | **Consumer** | `.PollInterval()`, `.ChangeTracking()`, `.InitialLoad()` | | **Protocol** | `.ProtocolVersion()`, `.Referrals()` | | **Pool** | `.MaxConnections()` | | **TLS** | `.TrustAllCertificates()`, `.ClientCert()` | > Most builder methods accept both constant values and `IExpression` for runtime resolution via the expression engine. ## Exchange Headers | Header | Description | |--------|-------------| | `redbLdap.Operation` | Operation type (Search, Add, etc.) | | `redbLdap.BaseDn` | Base DN used in the operation | | `redbLdap.Filter` | LDAP filter applied | | `redbLdap.Scope` | Search scope (Base, OneLevel, Subtree) | | `redbLdap.ResultCount` | Number of entries returned | | `redbLdap.SearchTime` | Search duration in milliseconds | | `redbLdap.Server` | Target LDAP server | | `redbLdap.Port` | Target port | | `redbLdap.Ssl` | Whether SSL/TLS was used | | `redbLdap.ChangeType` | Change type for Watch consumer | ## Change Tracking Modes | Mode | Description | |------|-------------| | `ModifyTimestamp` | Polls using `modifyTimestamp` attribute (standard LDAP) | | `Usn` | Polls using `uSNChanged` attribute (Active Directory) | | `Persistent` | Persistent search control (if supported by server) | ## Docker (for testing) ```yaml services: openldap: image: osixia/openldap:1.5.0 ports: - "389:389" - "636:636" environment: LDAP_ORGANISATION: "redb" LDAP_DOMAIN: "redb.test" LDAP_ADMIN_PASSWORD: "admin" ``` ## Part of [redb.Route](../README.md) — ESB & EIP Framework for .NET ## Named connection factory Keep credentials out of the route URI: register a factory in the context registry and reference it by name. A set-but-unknown name fails loud at startup — a typo can never silently fall back to inline URI parameters. ```csharp context.AddToRegistry("prod", new LdapConnectionFactory { Server = "dc01.corp.local", BindDn = "CN=svc,OU=Service,DC=corp,DC=local", BindPassword = secrets.LdapPassword, }); // ldap:SEARCH:dc=corp,dc=local?connectionFactory=prod ``` ## Tracing On the `redb.Route` activity source (`AddSource("redb.Route")`), with `network.protocol.name` = `ldap` and `redb.route.endpoint`: - **Consumer (WATCH).** One `Consumer` span, `ldap {baseDn} receive`, per routed entry. An entry carries no trace context, so the span is a root, never a child of the activity the poll loop inherited from whoever started the routes; a poll that finds nothing opens none. A failed route marks it an error, whether the failure stays on the exchange or escapes the pipeline; our own stop does not. - **Producer.** One `Client` span per operation, `ldap.{operation}`, with the `ldap.*` tags; an error when the operation fails, unless our own token cancelled it. A rejected `BIND` is an answer, not a failure: it is on `ldap.bind_result`. - `RouteEngineOptions.EnableTelemetry = false` opens neither span.