DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
512 stars 44 forks source link

[Support] Usage of inside() #670

Closed lukas-staab closed 11 months ago

lukas-staab commented 11 months ago

Environment:

I am unsure if this is a bug, or if I just misunderstood the docs. Having:

    public function save(){
        $c = Committee::findByOrFail('ou', $this->ou);
        $r = new Group([
            'cn' => 'group1,
            'description' => $this->description,
            'uniqueMember' => '',
        ]);
        $r->inside($c);
        $r->save();

        return redirect()->route('committees.roles', ['ou' => $this->ou])
            ->with('message', __('New Role created'));
    }

I would expect the Role Group below the Committee DN, seems like it is not below, but the exact DN. Am I missing something? The doc was not clear here for me. https://ldaprecord.com/docs/core/v3/model-api/#inside

Let the DN of Committee be ou=com1,dc=local,dc=net i would expect that the Group would have the DN cn=group1,ou=com1,dc=local,dc=net but instead i just got an error ldap_add(): Add: Already exists

stevebauman commented 11 months ago

@lukas-staab Nope you're understanding the feature correctly @lukas-staab!

That's strange, as I have test cases surrounding this 🤔

https://github.com/DirectoryTree/LdapRecord/blob/17540a7740964418c1eba251d31369a276a48a76/tests/Unit/Models/ModelTest.php#L139-L160

Could you try dumping the value of $r->getCreatableDn() after calling $r->inside($c) and see what it's generating?

$c = Committee::findByOrFail('ou', $this->ou);

$r = new Group(['...']);

$r->inside($c);

dd($r->getCreatableDn());
lukas-staab commented 11 months ago

Huh, strangely i cannot reproduce it anymore. Sorry for the wrong alarm. Closing for now...

Thanks for the reply!

stevebauman commented 11 months ago

No worries at all! Glad you're up and running!