By Manny Fernandez

November 29, 2026

LDAPS Tester: Troubleshoot LDAP and LDAPS Connections Layer by Layer

LDAPS Tester: Troubleshoot LDAP and LDAPS Connections Layer by Layer

No fluff. Just the config that works.

Every firewall, VPN concentrator, NAC and wireless controller eventually needs to talk to Active Directory over LDAPS. When it breaks, the appliance usually gives you one line: server unreachable or authentication failed. That line hides five different layers that can fail: DNS and TCP, the TLS handshake, certificate trust, the name check, and the bind itself. LDAPS Tester is a small open source utility we built to troubleshoot LDAPS connections one layer at a time, so you know exactly which layer broke and why.

Objective Install LDAPS Tester, use it to prove an LDAPS or StartTLS connection end to end, and read its output to fix certificate, name, bind and search failures.
Target audience Network and security engineers integrating appliances (FortiGate, FortiAuthenticator, NAC, wireless, VPN) with Active Directory or OpenLDAP, and AD admins rolling out LDAPS.
Release v0.1.1, source and builds on GitHub: infosecmonkey/ldaps-tester

Why We Built LDAPS Tester

The usual toolkit for this is ldapsearch, openssl s_client and a packet capture. They work, but each one only sees part of the problem. openssl s_client shows you the certificate but never binds. ldapsearch binds, but its TLS errors depend on which TLS library it was built against and which environment variables are set, and a failure often reads as Can’t contact LDAP server no matter what actually went wrong.

LDAPS Tester runs the whole conversation the way a real client would and stops at the first step that fails. Every step prints what it saw (addresses tried, the chain the server presented, SANs, fingerprints, bind result codes) and, when something fails, a plain-English hint about what to change. It ships as a GUI and a CLI that run the same test code, so the result you get on the command line is the result you get in the window.

  • LDAPS (TLS from the first byte, port 636) or plain LDAP upgraded with StartTLS (port 389).
  • Trust anchors from PEM, DER/.cer or PKCS#12 (.p12/.pfx), optionally plus the macOS system trust store.
  • Connect by IP and still verify the certificate against the hostname with a separate TLS name.
  • Simple bind with a full DN or an AD UPN, or anonymous.
  • Optional WhoAmI (RFC 4532) and a test search, so you can prove the lookup an appliance will do.
  • Active Directory data sub-codes translated (wrong password vs. locked vs. expired).
  • Exit codes for scripting: 0 success, 1 test failed, 2 bad command line.

Prerequisites and Architecture

Assumed knowledge: basic LDAP terms (DN, base DN, bind), and where your PKI lives. Lab: one domain controller with an LDAPS certificate, a workstation that can reach it, and a service account.

Component Lab value Notes
Workstation 10.0.10.50 Runs LDAPS Tester. Test from the same segment as the appliance when you can.
Domain controller dc01.corp.local / 10.0.0.10 TCP 636 for LDAPS, TCP 389 for StartTLS.
Root CA certificate corp-root-ca.cer Exported from the enterprise CA. Not the DC’s own certificate, unless you mean to pin.
Service account svc_ldap@corp.local Least-privilege read account, the same one the appliance will use.
Base DN DC=corp,DC=local Only needed for the test search.

What the test does

The test runs these steps in order and stops at the first failure:

Step What it proves Prints
[1] Loading trust anchors Your CA files are readable and are the certificates you think they are Subject, issuer, validity, SANs, CA flag, SHA-256
[2] TCP connection DNS resolves and the port is open from where you are Each address tried and connect time
[3] TLS handshake and certificate check The chain leads to a loaded CA and the name matches Presented chain and a verdict: trusted, pinned, insecure or failed
[4] Bind The credentials are accepted Bind result, with AD sub-codes decoded
[5] WhoAmI (optional) Who the server thinks you are Authorization identity, for example u:CORP\svc_ldap
[6] Test search (optional) The base DN and filter return the user the appliance will look up Entries and attributes

The TLS verdict is the part worth learning. trusted means full chain validation plus a name match, the same as a real client. pinned means the server’s own certificate is byte-for-byte one of the files you loaded, and the tool also tells you what full validation would have said. insecure means it only passed because you used -k, and it shows what would have failed. failed comes with a hint.

Step-by-Step: Troubleshoot LDAPS with LDAPS Tester

Step 1: Install and launch

Goal: Get the tool running in both modes.

Action: Download the build from the v0.1.1 release page and put the binary on your PATH. With any options it runs as a CLI; with no arguments, or with gui, it opens the window.

ldaps-tester --version
ldaps-tester --help      # options and examples
ldaps-tester             # no arguments: opens the GUI
ldaps-tester gui         # same

GUI verification: The window opens with Server, Certificate, Bind, After binding and Connection sections on the left and an empty log on the right.

Step 2: Get the right certificate

Goal: Load the certificate a real client would trust: the root CA that issued the DC certificate.

Action: On a Windows CA or DC, open certlm.msc, go to Trusted Root Certification Authorities, right-click the root, then All Tasks, Export. DER encoded binary and Base-64 both work.

You have Load it with -c? What happens
The issuing root CA Yes, recommended Full chain validation plus a name check, like a real client.
An intermediate CA Yes, with the root, or alone if the server sends the rest Chain validated up to a certificate you loaded.
The server’s own certificate Yes Accepted as a pin if it matches exactly. Good for self-signed servers. The output warns that full validation would fail.
A full chain in one PEM Yes Every certificate in the file is loaded.
A .pfx with the server’s private key Works, certificates only The key is ignored. Export just the CA instead.

GUI verification: Click Add certificate… or drop the file on the window. Format stays on Detect automatically. The log’s step [1] should list the file with CA certificate, self-signed for a root.

Step 3: Look at what the server presents

Goal: See the certificate before you trust anything or send a password.

Action: Run with -k and no bind. The tool still runs full validation and prints what would have failed, it just does not stop there.

ldaps-tester -H 10.0.0.10 -k

GUI verification: Tick Skip certificate verification (diagnostics only) and Anonymous bind. Step [3] lists the chain with SANs and issuer. Use the issuer line to know which CA to export in Step 2.

Warning: -k is for looking, never for proving. A pass with -k tells you nothing about whether the appliance will trust the server.

Step 4: Run the full LDAPS test

Goal: Prove TCP, TLS, trust, name, bind and identity in one run.

Action: Bind with the service account’s UPN (or full DN) and add --whoami. Leave out -w and the tool prompts for the password without echoing it.

ldaps-tester -H dc01.corp.local -c corp-root-ca.cer \
  -D svc_ldap@corp.local --whoami

# Full DN instead of a UPN
ldaps-tester -H dc01.corp.local -c corp-root-ca.cer \
  -D 'CN=svc_ldap,OU=Service Accounts,DC=corp,DC=local'

GUI verification: Fill Host / IP, keep Mode on LDAPS, enter Bind DN / UPN and Password, tick Run WhoAmI, then Run test (Command + Return also runs it). The header turns green with SUCCESS and step [5] shows the authorization identity.

Figure 1: LDAPS Tester GUI: a successful LDAPS run against a lab domain controller, trusted chain, UPN bind and WhoAmI.

LDAPS Tester GUI showing a successful LDAPS test with trusted certificate chain, bind and WhoAmI identity

Step 5: Test by IP, the way a firewall sees it

Goal: Reproduce an appliance that points at the DC by IP address.

Action: Connect to the IP and verify the certificate against the hostname with --tls-name. The name is also sent as SNI; the TCP connection still goes to -H.

ldaps-tester -H 10.0.0.10 --tls-name dc01.corp.local \
  -c corp-root-ca.cer -D svc_ldap@corp.local

GUI verification: Put the IP in Host / IP and the hostname in Verify name. Step [3] shows verifying certificate against name: dc01.corp.local.

Step 6: Test the user lookup

Goal: Prove the base DN, filter and attributes your appliance will use actually return the user.

Action: Add -b, -f and -a. Hitting --limit (default 5) is a note, not a failure.

ldaps-tester -H dc01.corp.local -c corp-root-ca.cer \
  -D svc_ldap@corp.local --whoami -b 'DC=corp,DC=local' \
  -f '(sAMAccountName=jdoe)' -a cn,mail,memberOf,userAccountControl

# First 20 groups under an OU, one level deep
ldaps-tester -H dc01.corp.local -c corp-root-ca.cer \
  -D svc_ldap@corp.local -b 'OU=Groups,DC=corp,DC=local' \
  --scope one -f '(objectClass=group)' -a cn --limit 20

GUI verification: Tick Test search and fill base, filter, scope and attributes. Step [6] prints each DN and its attributes. Binary attributes such as objectGUID show as a value count.

Step 7: StartTLS on 389

Goal: Test appliances that use plain LDAP upgraded with StartTLS.

Action: Add --starttls. The port defaults to 389.

ldaps-tester -H ldap.example.com --starttls -c ca.pem \
  -D 'cn=reader,dc=example,dc=com'

GUI verification: Select LDAP + StartTLS. Step [3] reads StartTLS negotiation instead of TLS handshake.

Step 8: Hand the working command to the appliance team

Goal: Turn a passing GUI run into something repeatable.

Action: Click Copy CLI command. It leaves passwords out, so it is safe to paste into a ticket. The same values map straight onto the appliance’s LDAP server object. On a FortiGate that means server name matching the certificate, port 636, the CA certificate imported, and server identity check left on.

config user ldap
    edit "DC01-LDAPS"
        set server "dc01.corp.local"
        set cnid "sAMAccountName"
        set dn "DC=corp,DC=local"
        set type regular
        set username "svc_ldap@corp.local"
        set password <password>
        set secure ldaps
        set port 636
        set ca-cert "CA_Cert_1"
    next
end

diagnose test authserver ldap DC01-LDAPS jdoe <password>

Verification and Validation

A good run ends with RESULT: SUCCESS and exit code 0. Lines start with ✔ for success, ! for a warning that does not fail the test (a pin, -k in use, an address that refused before another worked), and ✘ for the failure that stopped it.

[2] TCP connection
    ✔ dc01.corp.local resolves to 10.0.0.10
    ✔ connected to 10.0.0.10:636 in 14 ms

[3] TLS handshake and certificate check
      server presented 1 certificate(s):
      #1 (server)
        Subject : CN=dc01.corp.local
        Issuer  : DC=local, DC=corp, CN=corp-DC01-CA
        SANs    : DNS:dc01.corp.local
        Type    : end-entity certificate
    ✔ certificate chain trusted and valid for "dc01.corp.local"
    ✔ secure connection established in 27 ms

[4] Bind
      simple bind as svc_ldap@corp.local
    ✔ bind successful in 35 ms

[5] WhoAmI
    ✔ authorization identity: u:CORP\svc_ldap

RESULT: SUCCESS
Exit code Meaning
0 Every requested step succeeded
1 The test failed: connection, TLS, bind, WhoAmI, search, or an unreadable certificate file
2 Invalid command line (unknown option, missing –host)

Check every domain controller

Script on the exit code, not the text. The text is for people and may change between versions. Set LDAP_BIND_PASSWORD from your secrets store so the tool never waits at a prompt.

export LDAP_BIND_PASSWORD='...'   # better: read it from your secrets store
for dc in dc01 dc02 dc03; do
  if ldaps-tester -H "$dc.corp.local" -c corp-root-ca.cer \
       -D svc_ldap@corp.local >/dev/null 2>&1; then
    echo "OK    $dc"
  else
    echo "FAIL  $dc"
  fi
done

Troubleshooting and Gotchas

Gotcha 1: The certificate is not issued for the name you used

The most common LDAPS failure on appliances is pointing at the DC by IP while the certificate only lists the FQDN. Microsoft requires the DC’s FQDN in the subject CN or a DNS SAN, and IP SANs are rare. LDAPS Tester prints the names the certificate is valid for, right under the failure:

hint: the certificate is not issued for "10.0.0.10".
      it is valid for: DNS:dc01.corp.local
✘ certificate verification failed: invalid peer certificate:
  certificate not valid for name "10.0.0.10"

Fix: point the appliance at the FQDN, or keep the IP and set the TLS name (--tls-name here, the server identity name on the appliance).

Gotcha 2: Port 636 refuses, or the handshake ends with EOF

On AD, 636 only answers once the DC has a usable certificate: Server Authentication EKU (1.3.6.1.5.5.7.3.1), in the Local Computer Personal store, with the private key. Connection refused or the server never presented a certificate usually means the DC has no such certificate yet. A timeout instead points at a firewall dropping the traffic.

Gotcha 3: A bind that succeeds with no password

Send a DN with an empty password and many servers answer success. RFC 4513 calls this an unauthenticated bind: the DN is only for logging and you are treated as anonymous. It produces a false “it works”, so LDAPS Tester refuses it unless you add --allow-empty-password. If an appliance accepts blank passwords for users, this is the bug to look for.

Message reference

Message Likely cause What to do
Connection refused Nothing listening on that port Check the port. On AD, 636 needs an LDAPS certificate.
timed out during TCP Firewall dropping, or host unreachable Check routing and policy between you and the DC.
UnknownIssuer Chain does not lead to anything you loaded Load the root (and intermediate if the server does not send it). The hint names the top issuer.
certificate not valid for name Name or IP not in the certificate Use a listed name, or add –tls-name.
certificate expired / not valid yet Dates out of range Renew, or check both clocks.
MAC tag mismatch (wrong password?) Wrong PKCS#12 password Check –p12-password or LDAPS_P12_PASSWORD.
rc=8 strongerAuthRequired Server requires signing or TLS This tool always uses TLS, so you are hitting the wrong server or port.
rc=32 noSuchObject Base DN does not exist Check -b, AD style is DC=corp,DC=local.
rc=1 operationsError (AD) Search without an authenticated bind Bind with -D. AD does not allow anonymous searches.

Active Directory rc=49 sub-codes

For rc=49 invalidCredentials, AD appends a data code. LDAPS Tester decodes it so you can tell a typo from a locked account:

data Meaning
525 User not found
52e Wrong password (username is valid)
530 Logon not permitted at this time
531 Logon not permitted from this workstation
532 Password expired
533 Account disabled
701 Account expired
773 User must reset password
775 Account locked out

Password hygiene

Avoid -w on shared machines: it lands in shell history and the process list. Use the prompt, or LDAP_BIND_PASSWORD and LDAPS_P12_PASSWORD in scripts. The GUI never saves passwords.

Get LDAPS Tester

Source, builds and the full CLI reference are on GitHub: LDAPS Tester v0.1.1. Issues and pull requests are welcome.

Sources

OpenLDAP Server on Ubuntu 24.04: Deploy, Configure and Use It

OpenLDAP Server on Ubuntu 24.04: Deploy, Configure and Use It

Deploy an OpenLDAP server on Ubuntu 24.04: install slapd, add users and groups, enforce TLS and ACLs, then connect SSSD and FortiGate.

Read More
Demystifying FortiAuthenticator: Deploying FortiAuthenticator as an LDAP Server for Centralized FortiGate Authentication

Demystifying FortiAuthenticator: Deploying FortiAuthenticator as an LDAP Server for Centralized FortiGate Authentication

Deploy FortiAuthenticator as an LDAP server for centralized FortiGate authentication. Configure the directory tree, bind accounts, and secure network access.

Read More
Binding to LDAP with Minimum Access

Binding to LDAP with Minimum Access

Configure a FortiGate LDAP bind user with minimum access rights. Avoid Domain Admin privileges for secure LDAP authentication and SSL-VPN setup.

Read More