Is your feature request related to a problem? Please describe.
App\Classes\Template::getNextNumber() currently always selects the first available number starting from pla.template.getnextnumber.<attr>.
For example, if numbers 5000 through 5114 have been allocated but 5017 was freed by deleting a user, the next entry created receives uidNumber=5017 instead of 5115.
In POSIX/Samba environments, reusing a freed uidNumber or gidNumber can be unsafe. The old numeric ID may still be referenced by file ownership, home directories, backups, or ACLs. Reassigning it can therefore unintentionally grant the new account access to files belonging to the previous account.
Describe the solution you'd like
Add a configurable allocation strategy alongside the existing per-attribute starting values, for example:
'getnextnumber' => [
'uidnumber' => env('LDAP_TEMPLATE_UIDNUMBER_START', 1000),
'gidnumber' => env('LDAP_TEMPLATE_GIDNUMBER_START', 1000),
'strategy' => env('LDAP_TEMPLATE_GETNEXTNUMBER_STRATEGY', 'first_gap'),
],
The supported strategies could be:
first_gap: select the first available number from the configured starting value. This is the current behavior and should remain the default for backward compatibility.
max_plus_one: scan all existing values and return the highest value found plus one.
For max_plus_one, the maximum should be determined only after the complete directory scan, including the existing pagination/sizelimit loop, has finished.
Describe alternatives you've considered
The next value can be determined externally by querying all existing uidNumber or gidNumber values and calculating the maximum plus one. However, this requires manual work or separate provisioning logic and bypasses the convenience of the template’s automatic number allocation.
Increasing the configured starting value also does not solve the underlying issue, because gaps above that value can still be reused.
Additional context
The existing first_gap behavior should remain the default so that current installations are not affected.
I would be happy to submit a PR if this approach sounds reasonable. I wanted to confirm the preferred direction first because this changes shared numbering behavior.
Is your feature request related to a problem? Please describe.
App\Classes\Template::getNextNumber()currently always selects the first available number starting frompla.template.getnextnumber.<attr>.For example, if numbers 5000 through 5114 have been allocated but 5017 was freed by deleting a user, the next entry created receives
uidNumber=5017instead of 5115.In POSIX/Samba environments, reusing a freed
uidNumberorgidNumbercan be unsafe. The old numeric ID may still be referenced by file ownership, home directories, backups, or ACLs. Reassigning it can therefore unintentionally grant the new account access to files belonging to the previous account.Describe the solution you'd like
Add a configurable allocation strategy alongside the existing per-attribute starting values, for example:
The supported strategies could be:
first_gap: select the first available number from the configured starting value. This is the current behavior and should remain the default for backward compatibility.max_plus_one: scan all existing values and return the highest value found plus one.For
max_plus_one, the maximum should be determined only after the complete directory scan, including the existing pagination/sizelimit loop, has finished.Describe alternatives you've considered
The next value can be determined externally by querying all existing
uidNumberorgidNumbervalues and calculating the maximum plus one. However, this requires manual work or separate provisioning logic and bypasses the convenience of the template’s automatic number allocation.Increasing the configured starting value also does not solve the underlying issue, because gaps above that value can still be reused.
Additional context
The existing
first_gapbehavior should remain the default so that current installations are not affected.I would be happy to submit a PR if this approach sounds reasonable. I wanted to confirm the preferred direction first because this changes shared numbering behavior.