LDAP 2FA

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up ldap 2fa by linking your directory to a second factor tool. The system checks both a password and a temporary code before users log in. Many teams use this method for old apps that lack modern login support. They often map broad directory groups to database roles to save time. When a user logs in with those wide roles, they gain too much power. One valid login can expose every table or server command to human error. How ldap 2fa works in your architecture Standard directory service

LDAP Directory Services: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up ldap 2fa by linking your directory to a second factor tool. The system checks both a password and a temporary code before users log in. Many teams use this method for old apps that lack modern login support. They often map broad directory groups to database roles to save time. When a user logs in with those wide roles, they gain too much power. One valid login can expose every table or server command to human error.

How ldap 2fa works in your architecture

Standard directory services only check a username and a static password. A basic bind request does not have a field for a second code. To add a second step, admins place an adapter in the login flow. This service sits between the client app and the central directory server.

First, the user enters a username and password into the client app. Some setups ask the user to type the code right after the password. Other setups send a push alert to a phone after the password check. The adapter splits or reads the request and checks the password against the directory. Next, it talks to the second factor system to check the code or push. Both checks must pass before the directory returns a success message to the app. The app then reads the user group and grants a role for the session.

Choosing between code append and push alerts

Teams usually pick between two main ways to collect the second factor. The first way is the append method inside the standard password field. The user types their secret password and adds a six-digit code at the end. This works well for command line tools and old database clients. Those tools only show one box for a password and cannot show new screens.

The second way uses an out-of-band push alert to a mobile device. The user types only their normal password into the login screen. The login pauses while the phone asks the user to approve the request. This feels smoother for people, but it can cause network timeouts in old apps. If the user takes too long to tap their phone, the bind request fails. Teams must tune timeout limits on their database servers to stop false errors.

LDAP Directory Services: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What directory two-factor checks solve and what they miss

Adding a second factor to directory logins stops many basic attacks. Stolen passwords alone can no longer let an attacker into your network. It also helps teams meet strict rules for user login checks on old systems. You do not need to rewrite old apps just to check user identities.

Still, directory login checks only care about who starts the session. Once the bind request succeeds, the directory steps out of the way. It cannot see or control what the user does inside the open session. If an engineer logs into a production database, they get full role permissions. They can run a bad delete query or dump a table of emails. Standard directory logs only show that a user logged in at a specific time. They do not record the actual SQL queries or shell commands that ran. Also, shared service accounts often bypass two-factor rules so background jobs can run. Teams still need a way to inspect commands and mask fields like card numbers.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can native LDAP handle two-factor codes on its own?

Basic directory servers only check static passwords by default. You must add a plugin or an external radius server to check temporary codes.

How do command line tools work with ldap 2fa?

Command line tools cannot show a second prompt for a code. Users either append the code to their password or approve a mobile push alert.

Does ldap 2fa control what queries a user can run?

No, it only checks identity at the start of a session. Your database or server role still controls which commands or queries can run.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.