Path: redb-route/redb.Route.Ldap/LdapEntry.cs
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/LdapEntry.cs
----
namespace redb.Route.Ldap;
///
/// Typed LDAP directory entry (DN + attributes).
/// Returned by Search and Watch operations.
///
public sealed class LdapEntry
{
/// Distinguished Name of the entry.
public string Dn { get; set; } = "";
///
/// Attribute dictionary. Values are string for single-valued,
/// string[] for multi-valued, or byte[] for binary attributes.
///
public Dictionary Attributes { get; set; } = new();
/// Change type for consumer entries: "added", "modified", or "deleted".
public string? ChangeType { get; set; }
/// Gets a single-valued string attribute.
public string? GetString(string attr) =>
Attributes.TryGetValue(attr, out var v) ? v?.ToString() : null;
/// Gets a multi-valued string attribute.
public string[]? GetStringArray(string attr) =>
Attributes.TryGetValue(attr, out var v) ? v as string[] : null;
/// Gets a binary attribute value (first element if multi-valued).
public byte[]? GetBytes(string attr)
{
if (!Attributes.TryGetValue(attr, out var v)) return null;
if (v is byte[] single) return single;
if (v is byte[][] multi) return multi.Length > 0 ? multi[0] : null;
return null;
}
/// Gets a multi-valued binary attribute.
public byte[][]? GetBytesArray(string attr) =>
Attributes.TryGetValue(attr, out var v) ? v as byte[][] : null;
}