Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 632 - BASE_DN replacement everywhere #668

Merged
merged 13 commits into from
Nov 8, 2023
Merged

Conversation

stevebauman
Copy link
Member

Closes #632

This PR implements base DN substitution in more areas of LdapRecord to increase the convenience of its Active Record implementation -- namely object creation and renaming.

During Creation:

// base_dn = "dc=local,dc=com"

$user = (new User)->inside('ou=Accounting,{base}');

$user->cn = 'John Doe';

$user->save();

echo $user->getDn(); // "cn=John Doe,ou=Accounting,dc=local,dc=com"

During Rename:

// base_dn = "dc=local,dc=com"

$user = User::find('cn=John Doe,{base}');

$user->rename('Jane Doe', 'ou=Accounting,{base}');

echo $user->getDn(); // "cn=Jane Doe,ou=Accounting,dc=local,dc=com"

@lukas-staab Are there other places you would find base DN substitution useful? I thought of performing replacements inside of attributes during object creates/updates, but a bit concerned that could impact performance since we would have to cycle through all given attributes each time.

@stevebauman stevebauman merged commit 17540a7 into master Nov 8, 2023
12 checks passed
@lukas-staab
Copy link

Hi Steve,
inside every Attribute feels a bit to much for me as well, especially with the attach() methods it should be fine without (thinking about group memberships right now).

My original use case was that I wanted a object / class which knows where its personal root is. E.g. a set of groups which live in a special OU as siblings to each other. So if I create an object, or search with the query builder, the object knows where to search or instert by default. This is probably (better) doable with a global scope to the class right now.

All in all this will be a lot easier with this change. Thanks a lot!

@stevebauman
Copy link
Member Author

Hey Lukas, thanks for the reply! Ok great, I'm glad this will work for you. If you end up requiring it in any additional areas, drop by and give me a shout! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] BASE_DN replacement everywhere
2 participants