An LDAP server backed by the local POSIX user and group database. It lets LDAP-aware applications look up system accounts and authenticate users via PAM, without maintaining a separate directory.
The directory tree mirrors /etc/passwd and /etc/group:
dc=host,dc=example,dc=com
├── ou=people
│ ├── uid=alice,...
│ └── uid=bob,...
└── ou=groups
├── cn=staff,...
└── cn=wheel,...
Each user entry carries the standard posixAccount and inetOrgPerson
attributes (uid, cn, sn, uidNumber, gidNumber, homeDirectory,
loginShell, gecos). The GECOS field is parsed using the traditional
BSD format to populate givenName, roomNumber, telephoneNumber, and
homePhone when those fields are non-empty. Each group entry carries
posixGroup attributes (cn, gidNumber, memberUid).
Additional attributes can be added to user entries via the configuration file (see User attributes below).
Bind requests are authenticated via PAM. Anonymous binds are accepted by
default; use require_bind to restrict searches to specific accounts.
cargo build --release
Tagged releases on GitHub carry four packages, built natively on each architecture:
| Package | Built on | Installs on |
|---|---|---|
pwldapd_<ver>_amd64.deb, pwldapd_<ver>_arm64.deb |
Debian 13 (trixie) | Debian 13+, Ubuntu 25.04+ |
pwldapd-<ver>.x86_64.rpm, pwldapd-<ver>.aarch64.rpm |
Rocky Linux 10 | RHEL, Rocky, AlmaLinux 10+, current Fedora |
Each package installs:
/usr/sbin/pwldapd: the daemon binary (CAP_NET_BIND_SERVICEis granted by the systemd unit)/usr/share/man/man8/pwldapd.8: man page/etc/pam.d/pwldapd: default PAM configuration (a conffile; local edits are preserved on upgrade)/usr/lib/systemd/system/pwldapd.service: systemd unit
and creates the pwldapd system user and group. The service is enabled
automatically on install. To start it immediately:
sudo systemctl start pwldapdThe two families differ in how the daemon reads password hashes. On Debian
the unit adds the daemon to the shadow group so pam_unix can read
/etc/shadow directly, and the PAM file includes common-auth. Fedora and
RHEL have no shadow group, so there pam_unix runs its setuid
unix_chkpwd helper; the RPM unit therefore omits NoNewPrivileges and
keeps CAP_DAC_READ_SEARCH, CAP_SETUID and CAP_SETGID in the
capability bounding set, and the PAM file includes system-auth. The
packaging sources are under pkg/deb/ and pkg/rpm/.
Signed APT and dnf repositories are published to https://6d7770.github.io/pwldapd/ by the release workflow. Packages and repository metadata are signed with this key:
pub rsa4096 2026-10-25 [SC]
6AD7 2F9B 8BFD 5547 01AD 9FE2 3FF4 0033 C2B9 10AF
uid pwldapd package signing <michael@paddon.org>
Debian and Ubuntu:
sudo install -d /usr/share/keyrings
curl -fsSL https://6d7770.github.io/pwldapd/pwldapd-archive-keyring.gpg \
| sudo tee /usr/share/keyrings/pwldapd-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/pwldapd-archive-keyring.gpg] \
https://6d7770.github.io/pwldapd/deb stable main" \
| sudo tee /etc/apt/sources.list.d/pwldapd.list
sudo apt update && sudo apt install pwldapdRHEL, Rocky, AlmaLinux and Fedora:
sudo dnf config-manager --add-repo \
https://6d7770.github.io/pwldapd/rpm/pwldapd.repo
sudo dnf install pwldapdOn dnf 5 (Fedora 41 and later) the first command is
sudo dnf config-manager addrepo --from-repofile=<url>.
The repositories are regenerated by pkg/apt/publish.sh on every tagged
release: the APT Release file, every RPM and the rpm metadata are all
signed with one GPG key. Publishing requires the APT_SIGNING_KEY
repository secret, an ASCII-armored GPG private key with no passphrase
(RSA 4096 is the safe choice for compatibility with older rpm); when it
is absent the release still happens and the repository step is skipped.
cargo install cargo-deb cargo-generate-rpm
cargo build --release
cargo deb --no-build # -> target/debian/*.deb
cargo generate-rpm # -> target/generate-rpm/*.rpmPackages built on your own machine depend on the glibc installed there;
the release workflow builds inside debian:trixie and
rockylinux/rockylinux:10 containers so that the published packages have
a known baseline.
pwldapd [-c FILE]
If -c is not given, pwldapd looks for /etc/pwldapd.toml and loads it
if present. Without any config file it starts with built-in defaults:
listening on 127.0.0.1:389, base DN derived from the system hostname, and
all UIDs and GIDs served.
Load a TOML configuration file with --config (or place it at
/etc/pwldapd.toml for automatic loading). An example covering every option:
include = ["/etc/pwldapd.d/*.conf"]
listen = ["127.0.0.1:389"]
tls_listen = ["[::]:636"]
unix_listen = ["/run/pwldapd/ldap.sock"]
base_dn = "dc=example,dc=com"
uid_ranges = ["1000-65535"]
gid_ranges = ["1000-65535"]
tls_cert = "/etc/ssl/certs/ldap.pem"
tls_key = "/etc/ssl/private/ldap.key"
log_level = "info"
require_bind = ["svcaccount"]
idle_timeout = 300
max_connections = 256
[user_attributes]
mail = "{uid}@example.com"
department = "Engineering"
[user_overrides.alice]
mail = "alice@external.com"
department = "Platform Engineering"The include field takes a list of glob patterns. Each matching file is
loaded and merged before the values in the main file; the main file always
takes precedence. Included files may not themselves contain include
directives.
A port may be omitted from listen and tls_listen addresses; :389
and :636 are appended automatically. To suppress the default TCP listener
(127.0.0.1:389), set listen = [] explicitly.
Unknown keys in the file are treated as errors so that typos are caught at startup rather than silently ignored.
The [user_attributes] section adds or replaces attributes on every user
entry. Values are either fixed strings or templates containing
{placeholder} sequences:
| Placeholder | Value |
|---|---|
{uid} |
Username |
{cn} |
Common name (from GECOS) |
{sn} |
Surname (last word of cn) |
{uidNumber} |
Numeric UID |
{gidNumber} |
Numeric GID |
{homeDirectory} |
Home directory path |
{shell} |
Login shell |
{gecos} |
Raw GECOS field |
An unknown placeholder such as {email} is a fatal error at startup.
Values in [user_attributes] may replace built-in attributes such as
loginShell or cn. The core identity attributes objectClass, uid,
uidNumber, and gidNumber are protected and cannot be replaced; attempts
produce a warning and are ignored.
The [user_overrides.<username>] section sets fixed attribute values for
a specific user. These take precedence over the general [user_attributes]
rules. Templates are not supported in per-user overrides.
If base_dn is not set in the config file, the base DN is derived from the
fully-qualified hostname. For example, on a host named server.example.com
the base DN becomes dc=server,dc=example,dc=com. If the hostname is
unqualified, pwldapd attempts a DNS canonical-name lookup to find the FQDN.
Use bracket notation for IPv6 addresses in listen and tls_listen:
listen = ["[::1]:389"]
tls_listen = ["[::]:636"]Port 389 requires elevated privileges. When installed from the Debian
package, the systemd unit runs pwldapd as the unprivileged pwldapd
system user and grants CAP_NET_BIND_SERVICE via AmbientCapabilities,
so no additional configuration is needed.
When running outside of the package, grant the capability directly:
sudo setcap cap_net_bind_service=ep ./target/release/pwldapd
Alternatively, use a high port and redirect with a firewall rule, or run under a service manager that provides socket activation.
Set tls_listen, tls_cert, and tls_key in the config file to accept TLS
connections. Plain and TLS listeners can run together:
listen = ["127.0.0.1:389"]
tls_listen = ["[::]:636"]
tls_cert = "/etc/ssl/certs/ldap.pem"
tls_key = "/etc/ssl/private/ldap.key"Set unix_listen to a list of socket paths to accept connections over a
Unix domain socket. This is useful for local clients that do not need
network access:
unix_listen = ["/run/pwldapd/ldap.sock"]Each entry can also be an inline table with optional owner, group, and
mode fields:
unix_listen = [
{ path = "/run/pwldapd/ldap.sock", owner = "root", group = "ldap", mode = "660" },
]mode is a string of octal digits ("660" or "0660"). A bare integer
(660) is also accepted and read digit-for-digit as octal, but do not
write a TOML octal literal such as 0o660: TOML converts it to the
decimal 432 before pwldapd sees it. If mode is omitted the socket is created with the system
default permissions (the process umask applies as normal). If owner or
group is omitted the socket's ownership is not changed. Both owner and
group accept either a name or a numeric UID/GID.
Multiple paths are supported, and the two forms may be mixed:
unix_listen = [
"/run/pwldapd/plain.sock",
{ path = "/run/pwldapd/restricted.sock", group = "ldap", mode = "660" },
]Plain TCP, TLS, and Unix listeners can all run simultaneously.
If a socket file already exists at the path when the daemon starts (e.g. from a previous run), it is removed and recreated automatically. Anything else at that path (a regular file, a directory) is left alone and the daemon refuses to start. Socket files are removed again on SIGTERM or SIGINT.
Clients connect using the ldapi:// URI scheme. With ldapsearch:
ldapsearch -H ldapi:///run/pwldapd/ldap.sock -x -b dc=example,dc=com
Use uid_ranges and gid_ranges to limit which accounts and groups are
served. Multiple disjoint ranges are supported:
uid_ranges = ["1000-65535", "200", "201"]
gid_ranges = ["1000-65535"]Without gid_ranges, all groups are served. Primary groups of served users
are always visible regardless of the GID range. Accounts excluded by
uid_ranges are also removed from the memberUid lists of the groups
that are served.
Users and groups come from the system NSS databases via getpwent(3) and
getgrent(3), so any source configured in /etc/nsswitch.conf (not only
/etc/passwd and /etc/group) is exposed.
By default any client, including unauthenticated anonymous clients, may
perform searches. Set require_bind to a list of account names to restrict
this: a client must successfully bind as one of those accounts before any
search request is permitted.
require_bind = ["svcaccount"]This is intended for service accounts that need to authenticate themselves
to the server before retrieving directory data. When require_bind is set:
- An anonymous bind succeeds but subsequent searches return
INSUFFICIENT_ACCESS_RIGHTS(LDAP result code 50). - The bind DN must be
uid=<name>,ou=people,<base_dn>or a bare account name. Auid=component under any other parent is rejected. - A bind as an account not in the list fails with
INVALID_CREDENTIALS(the account is rejected by PAM), so searches remain blocked. - A bind as a listed account succeeds; searches are then permitted for the remainder of that connection.
- Re-binding anonymously or failing a bind clears the authenticated identity; searches are blocked again until a successful bind.
When require_bind is empty (the default) all clients may search without
binding.
Log verbosity can be set in the config file:
log_level = "debug"Or with the RUST_LOG environment variable (takes precedence over the config file):
RUST_LOG=pwldapd=debug pwldapd
Both accept full tracing filter syntax, e.g. "pwldapd=debug" or "debug". The default is pwldapd=info.
pwldapd authenticates bind requests through the PAM service named
pwldapd. Create /etc/pam.d/pwldapd before starting the daemon.
A minimal configuration that delegates to the standard system auth stack:
auth required pam_unix.so
account required pam_unix.so
Or, on systems that use the include-based layout:
@include common-auth
@include common-account
Using a dedicated service name lets you apply LDAP-specific policies independently of console login, for example adding a failure delay or restricting which accounts may bind via LDAP.
idle_timeout (seconds, default 300) closes a connection that has sent
nothing for that long; 0 disables the timeout. max_connections
(default 256) caps the number of simultaneous client connections across
all listeners; further connections are accepted and immediately closed
until a slot frees up. Individual LDAP messages larger than 1 MiB are
rejected.
Run the unit tests and lints with:
cargo test
cargo clippy --all-targets -- -D warnings
Test coverage is measured with cargo-llvm-cov:
cargo install cargo-llvm-cov
rustup component add llvm-tools
cargo llvm-cov --summary-only # per-file table
cargo llvm-cov --html # report in target/llvm-cov/html
CI fails if line coverage drops below 90%. The tests need no network access, root privileges or LDAP client tools; the protocol tests drive the handler over in-memory pipes and loopback sockets, and TLS tests generate a throwaway certificate at run time.
pwldapd is intentionally a read-only LDAP front-end.
- Write operations: Add, Delete, Modify, ModifyDN and Compare requests
receive
unwillingToPerform(result code 53). The connection stays open. - SASL authentication: only simple binds (anonymous or
username/password) are supported. SASL binds receive
authMethodNotSupported(result code 7). - StartTLS and other extended operations receive
unwillingToPerform. Use a dedicated LDAPS port (tls_listen) instead. - Filters: equality, presence, substring,
>=,<=, AND, OR and NOT are evaluated.>=and<=compare numerically when both sides are integers (so(uidNumber>=1000)works) and case-insensitively otherwise. Approximate and extensible matches never match. - Time limits: the client-requested
sizeLimitis honoured (sizeLimitExceeded, result code 4, when truncated);timeLimitis ignored. - Referrals, server-side sorting, persistent searches and change notifications are not supported.
Point your LDAP client at the daemon. With nss-pam-ldapd or sssd, use:
uri ldap://127.0.0.1/
base dc=host,dc=example,dc=com
Or, if you configured a Unix domain socket:
uri ldapi:///run/pwldapd/ldap.sock
base dc=host,dc=example,dc=com
Replace the base DN with whatever pwldapd logs at startup.