teltek/pumukit-ldap-bundle
A Symfony bundle that adds LDAP authentication and directory user integration to Pumukit. It lets installations validate credentials against LDAP and map directory accounts and groups into Pumukit’s user model, with configurable connection and filter settings.
The package is small and Pumukit-specific, so treat it as an integration layer rather than a standalone LDAP library. Your first job is confirming compatibility, not learning an API.
Minimal steps:
composer.json and read the require / provide sections — match them against your pumukit/pumukit version before touching anything else.composer require teltek/pumukit-ldap-bundle.app/AppKernel.php (or config/bundles.php on newer Symfony) — it must load after the Pumukit core bundles so its compiler passes and service decorators can hook in.php -m | grep ldap should return ldap. There is no pure-PHP fallback in this bundle.DependencyInjection/Configuration.php in the vendor tree. That file is the authoritative list of config keys — the README is thin and frequently behind the code. Read the config tree before writing any YAML.Resources/config/services.xml. That tells you exactly which firewall key it expects to be wired into.First concrete use case — authenticate against LDAP while keeping Pumukit’s own session/User persistence:
# config/config.yml (or config/packages/pumukit_ldap.yaml)
pumukit_ldap:
server:
host: ldap.example.org
port: 389 # 636 for LDAPS
# bind credentials as required by your directory
# attribute mapping, base DN, filter — see Configuration.php for exact keys
Then point a firewall at the bundle’s provider rather than the default pumukit one, and confirm on a staging server that a known LDAP login lands on the Pumukit dashboard with the correct local user (or creates one, if auto-provisioning is on).
1. Authenticate-then-provision. The typical flow: user presents credentials → bundle binds to LDAP → on success, a Pumukit User is looked up by username, and created or updated on the fly. Use this to seed Pumukit users from your directory so nobody maintains parallel accounts. Keep provisioning idempotent — the bundle may call it on every login.
2. Metadata-first filling. This is the bundle’s named selling point. After a successful bind, read directory attributes (cn, mail, telephoneNumber, o/ou, custom schema attrs) and copy them into the Pumukit Person/User fields. The pattern is a service that takes the LDAP entry array and maps it to your entity fields — keep the mapping explicit in config or a small mapper class, because attribute names differ wildly across directories (OpenLDAP vs. Active Directory vs. eDirectory).
3. Decorate, don’t fork. If the bundle’s mapper doesn’t cover your attributes, register a compiler pass or use service decoration to wrap the bundle’s mapper/provider. Vendor-editing is the wrong path given how sparsely maintained this package is — decorate and keep your code in src/.
4. Environment-split config. Define the LDAP host/port/base DN per environment in parameters.yml / .env. Use a local OpenLDAP container (e.g., osixia/openldap) for dev/test so you never accidentally point a debug build at production AD.
5. Sync as a command, not just on login. For existing users or when metadata drifts, write a Symfony console command that iterates local users and refreshes their attributes from LDAP. Wrap it in a cron. This is usually where most of the day-to-day business value is realized — login-time filling only helps new sessions.
6. Firewall integration. Wire the bundle as an additional authenticator on your Pumukit firewall (or a dedicated ldap firewall for admin tools) rather than a full replacement, so local fallback accounts remain usable while you validate the LDAP path.
7. Test with a known-good ldapsearch first. Before debugging the bundle, confirm the connection works outside Symfony: ldapsearch -H ldap://host -D 'binddn' -w pass -b 'base' '(uid=test)'. If that fails, the bundle will fail the same way — save yourself the round trips.
ext-ldap surfaces as cryptic “Unable to connect” errors rather than an install-time failure. Add "ext-ldap": "*" to your own composer.json to fail fast.User construction. Pin pumukit/pumukit and this bundle together, and re-run integration tests after every Pumukit bump.DependencyInjection/Configuration.php. Keep an eye on the repository’s open issues before relying on edge-case features.* or parentheses) can broaden matches. Escape user-supplied values with ldap_escape($value, '', LDAP_ESCAPE_FILTER) before building the search filter.ldap_* functions and in the bundle’s config. Many AD servers require one specific path — test both, and remember certificate trust is a system-level concern (/etc/ldap/ldap.conf, or TLS_REQCERT), not something the bundle manages.memberOf as a multi-valued attribute and paged results for large searches; some LDAP libraries handle paging automatically, some don't. If group-based authorization is expected, verify the attribute is actually populated before writing logic against it.ldapsearch output to avoid silent “attribute not found” mapping misses.config.yml. Rotate it independently of application deploys.ldap_set_option($ds, LDAP_OPT_DEBUG_LEVEL, 7)) in a throwaway script, not in the bundle — it dumps raw wire traffic to stderr and is unusable in production logs.symfony/ldap directly, keeping this bundle only for the Pumukit-side provisioning glue.How can I help you explore Laravel packages today?