using ZB.MOM.WW.Auth.Abstractions.Ldap; namespace ZB.MOM.WW.MxGateway.Server.Configuration; /// /// Gateway-side view of the MxGateway:Ldap section. This is a SHADOW of the /// shared type and is NOT /// used to perform LDAP authentication at runtime — runtime bind/search is done by the /// shared ZB.MOM.WW.Auth.Ldap provider, whose options are bound directly from the /// same MxGateway:Ldap section by AddZbLdapAuth (see /// ). /// /// This shadow exists for three things only: (1) startup validation via /// ; (2) the redacted effective-config display /// ( / ); /// and (3) it is the single home of the gateway's dev/default LDAP values, which the /// integration live-test helper copies onto the shared options. /// /// /// Review C2 — DRIFT WARNING: this class MUST stay field-compatible with the shared /// so the one config section /// binds cleanly onto both. The two are intentionally NOT merged because their defaults /// differ on purpose: this shadow ships dev-friendly defaults (plaintext localhost, /// AllowInsecure=true, populated SearchBase/ServiceAccount*), whereas /// the shared type is secure-by-default (Transport=Ldaps, AllowInsecure=false, /// empty DN fields). If you add/rename/remove a field on the shared type, mirror it here /// (and in the validator + effective-config) so the section keeps binding to both. /// /// public sealed class LdapOptions { /// Gets a value indicating whether LDAP authentication is enabled. public bool Enabled { get; init; } = true; /// Gets the LDAP server address. public string Server { get; init; } = "localhost"; /// Gets the LDAP server port. public int Port { get; init; } = 3893; /// /// Gets the transport/TLS mode for the LDAP connection. Replaces the former /// boolean UseTls (true ≈ , false = /// ). upgrades /// a plaintext connection to TLS. Matches the shared /// field so the /// MxGateway:Ldap section binds straight onto the shared options. /// public LdapTransport Transport { get; init; } = LdapTransport.None; /// Gets a value indicating whether insecure (plaintext) LDAP connections are allowed. public bool AllowInsecure { get; init; } = true; /// Gets the LDAP search base distinguished name. public string SearchBase { get; init; } = "dc=zb,dc=local"; /// Gets the service account distinguished name. public string ServiceAccountDn { get; init; } = "cn=serviceaccount,dc=zb,dc=local"; /// Gets the service account password. public string ServiceAccountPassword { get; init; } = string.Empty; /// Gets the LDAP attribute name for user names. public string UserNameAttribute { get; init; } = "cn"; /// Gets the LDAP attribute name for display names. public string DisplayNameAttribute { get; init; } = "cn"; /// Gets the LDAP attribute name for group membership. public string GroupAttribute { get; init; } = "memberOf"; /// /// Gets the ordered fallback LDAP endpoints ("host" or "host:port") the shared /// provider walks when the primary fails with a system-side error. Empty (the default) leaves /// single-endpoint behaviour unchanged. Mirrors /// , added in /// ZB.MOM.WW.Auth 0.2.0. /// /// Carried here only so the effective-config display does not hide a configured backup DC — /// nothing on the gateway side reads it. Entry syntax is validated at boot by the shared /// LdapOptionsValidator, which owns the (internal) parser; re-validating here would /// mean a second, drifting copy of that grammar. /// /// public IReadOnlyList FallbackServers { get; init; } = []; }