Skip to content

feat(provisioning): Add possibility to use LDAP attributes within provisioning templates - #13500

Open
DerDreschner wants to merge 1 commit into
mainfrom
feat/provisioning-ldap-placeholder
Open

feat(provisioning): Add possibility to use LDAP attributes within provisioning templates#13500
DerDreschner wants to merge 1 commit into
mainfrom
feat/provisioning-ldap-placeholder

Conversation

@DerDreschner

Copy link
Copy Markdown
Contributor

At the moment, only the user id and the mail address attached to the account can be used within provisioning templates. This isn't enough for enterprise use-cases where the LDAP may contain attributes that need to be used within the provisioning template.

To enable that use-case, this PR adds a general %LDAP:...% placeholder that allows reading any LDAP attribute associated with the user account. Most often, this may be used for accessing the sAMAccountName via %LDAP:sAMAccountName%, but I've built it without limitations to that attribute for flexibility. In case the read-request fails (e.g., because the attribute doesn't exist), the placeholder isn't being replaced within the template (same behavior like %EMAIL%).

TO-DO

  • Add documentation about accessing LDAP attributes within provisioning templates

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

…visioning templates

Assisted-by: ClaudeCode:claude-fable-5
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner
DerDreschner force-pushed the feat/provisioning-ldap-placeholder branch from f89f49c to 49c00e5 Compare August 17, 2026 09:09
Comment thread lib/Db/Provisioning.php
*/
private const LDAP_PLACEHOLDER_PATTERN = '%LDAP:([A-Za-z][A-Za-z0-9-]*)%';
private const LDAP_PLACEHOLDER_REGEX = '/' . self::LDAP_PLACEHOLDER_PATTERN . '/';
private const LDAP_PLACEHOLDER_ANCHORED_REGEX = '/^' . self::LDAP_PLACEHOLDER_PATTERN . '$/';

@kesselb kesselb Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude flagged, that the current regex also matches a trailing newline:

php -r 'var_dump(preg_match("/^[A-Za-z0-9._+@-]{1,64}\$/", "BWAYNE\n"));'
Command line code:1:
int(1)

Add D modifier to prevent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants