Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011pgUiWfMnyGW1NXQHhV6qE
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It is a 1257-line new driver implementing a binary protocol (BER/RFC 4511) and RFC 4515 filter translation whose correctness cannot be fully verified without a live LDAP server, so it warrants human review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
This PR adds a new plugin LDAP driver (plugins/drivers/ldap.php) that lets Adminer browse and edit LDAP directories by mapping the directory tree onto Adminer's database/table/row/column model (naming context = database, entry = row keyed by dn, attribute = column). It follows the established plugin-driver pattern (like redis.php/simpledb.php): a Db connection class, a Driver, a Result, and the driver-level override functions. It ships two interchangeable clients — one using the PHP ldap extension, and a dependency-free client that speaks the needed subset of RFC 4511 over a socket (BER encoding/decoding plus an RFC 4515 filter translator). The change also extends the login-ssl plugin documentation to cover LDAP and records the new plugin in the changelog.
Changes:
- New
plugins/drivers/ldap.phpimplementing LDAP browsing/editing with two clients (extension and raw-socket), schema parsing, tree/class table mapping, search/sort/paging, and CRUD via modify/modrdn. - Documented LDAP SSL options in
plugins/login-ssl.php(StartTLS switch forldap://). - Added
New plugin ldap: LDAP driverunder the### Pluginschangelog subsection.
| File | Description |
|---|---|
| plugins/drivers/ldap.php | New LDAP plugin driver: dual clients (ldap ext + socket/BER), schema parsing, table/tree mapping, select with filters/sort/paging, insert/update/delete. |
| plugins/login-ssl.php | Adds an LDAP line to the SSL-options doc-comment describing the StartTLS behavior. |
| CHANGELOG.md | Records the new LDAP plugin driver under ### Plugins. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| foreach (preg_split('~\r\n|\r|\n~', (string) $value, -1, PREG_SPLIT_NO_EMPTY) as $val) { | ||
| $return[] = ($binary ? (string) base64_decode($val, true) : $val); | ||
| } |
|
Thanks! Is there a way for me to try it? Is there some public LDAP playground, similar to e.g. https://play.clickhouse.com/? |
|
Hi! There are public ldap servers that work with this code, e.g. forumsys:
But I developed it locally using random sample data inserted into 1. Start a demo LDAP serverdocker run -d --name ldap-demo -p 1389:1389 \
-e LDAP_ROOT=dc=example,dc=org \
-e LDAP_ADMIN_USERNAME=admin -e LDAP_ADMIN_PASSWORD=adminpassword \
-e LDAP_SKIP_DEFAULT_TREE=yes \
bitnamilegacy/openldap:latest
# wait until it accepts connections
until docker exec ldap-demo ldapsearch -x -H ldap://127.0.0.1:1389 -b "" -s base >/dev/null 2>&1; do sleep 1; done2. Load sample dataThis command creates cat > demo.ldif <<'EOF'
dn: dc=example,dc=org
objectClass: dcObject
objectClass: organization
dc: example
o: Example Inc.
dn: ou=people,dc=example,dc=org
objectClass: organizationalUnit
ou: people
dn: ou=engineering,ou=people,dc=example,dc=org
objectClass: organizationalUnit
ou: engineering
dn: ou=backend,ou=engineering,ou=people,dc=example,dc=org
objectClass: organizationalUnit
ou: backend
dn: ou=groups,dc=example,dc=org
objectClass: organizationalUnit
ou: groups
dn: uid=jnovak,ou=backend,ou=engineering,ou=people,dc=example,dc=org
objectClass: inetOrgPerson
uid: jnovak
cn:: SmnFmcOtIE5vdsOhaw==
sn:: Tm92w6Fr
title: Backend Lead
mail: jnovak@example.org
mail: jiri.novak@example.org
dn: uid=alice,ou=engineering,ou=people,dc=example,dc=org
objectClass: inetOrgPerson
uid: alice
cn: Alice Johnson
sn: Johnson
mail: alice@example.org
dn: cn=Doe\, John,ou=people,dc=example,dc=org
objectClass: inetOrgPerson
cn: Doe, John
sn: Doe
dn: cn=engineering,ou=groups,dc=example,dc=org
objectClass: groupOfNames
cn: engineering
member: uid=jnovak,ou=backend,ou=engineering,ou=people,dc=example,dc=org
member: uid=alice,ou=engineering,ou=people,dc=example,dc=org
EOF
docker exec -i ldap-demo ldapadd -c -x -H ldap://127.0.0.1:1389 \
-D "cn=admin,dc=example,dc=org" -w adminpassword < demo.ldifIt should print 3. Start AdminerFrom the php -S 127.0.0.1:80004. Log inOpen http://127.0.0.1:8000/adminer/?ldap=127.0.0.1%3A1389&username=cn%3Dadmin%2Cdc%3Dexample%2Cdc%3Dorg The system, server and user are already filled in. Enter the password To try the built-in client instead of the PHP extension, add Connecting to your own LDAP serverOn the login page, choose the system LDAP and fill in:
Stop and clean upPress Ctrl+C in the Adminer terminal, then run If something goes wrong
|
|
Thanks a lot for the driver and for the detailed instructions on trying it. I won't merge it into the repository, because I don't want to take on maintaining another driver. Please publish it as your own plugin (a repository with the single file is enough) and I'll link it from https://www.adminer.org/plugins/. There are already driver plugins published like this, e.g. https://www.adminer.org/plugins/#user-duckdb. I've taken only the change to Here is some feedback that might help the plugin. Line numbers are in Bugs
Login-ssl
Other
|





A plugin driver for browsing and editing LDAP directories based on the flattened tree -> db tables design described below. I use it internally but other people may find it useful too.
Mapping
dn, column = attributedn– its rows are its direct children (one-level search); these come first in the menu, each shown as its RDN indented under its parent, so the menu reads as the directory treeobjectClass– its rows are its entries in the whole naming contextMUSTattributes of the class plus the attributes populated in the first 50 rows (a class can allow dozens);binary, or the Active Directory GUID/SID) as base64dnis a modrdn, which can also move the entrydn =becomes the search baseConnection
ldapextension; without it, or withext=socket, a built-in client speaks the needed subset of RFC 4511 over a socket (like the Redis driver), so it also works on hosts without the extensionldaps://connects by TLS; plugin login-ssl switchesldap://to StartTLS and sets its certificates – with the ldap extension only for StartTLS, because libldap ignores the per-connection TLS options ofldaps://and usesldap.conf/LDAPTLS_CACERTthereLimitations
Open question: login-ssl options are global, so a setup using login-ssl for e.g. MySQL also switches LDAP to StartTLS. I chose it because there is no standard URL scheme for StartTLS – happy to change it.
Tested against OpenLDAP 2.6.10 on PHP 8.5 with both clients giving identical results: login, menu tree, select with search, sort and paging, row count, edit (including a no-op save of binary values), insert, multi-valued update with a move to another parent, delete, the non-leaf delete error, and StartTLS and
ldaps://with and without a trusted CA.php compile.php ldapandphp compile.php driversbuild without the missing-function warning, phpcs is clean andcomposer testpasses.Note for the pepa-linha design: it lays out the menu correctly only for table names that are links to a structure page, so drivers without one (this one, IMAP) get misaligned select links; that is a separate CSS fix.