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

Ldap::addAttributes() fails without throwing if bind() has not been called #2

Open
weierophinney opened this issue Dec 31, 2019 · 3 comments

Comments

@weierophinney
Copy link
Member

This one is bad. Other methods that require an ldap bind to have been made, like Ldap::search(), check if the connection is already bound and call Ldap::bind() if not, so users may be accustomed to skipping calling Ldap::bind() directly in user code. However, Ldap::addAttributes() does not do this, so if the Ldap instance doesn't already have a bound connection, we end up calling ldap_mod_add() with null as the ldap resource. Obviously, that doesn't work, but worse, ldap_mod_add returns null, not false, when it is given a null resource, and we only throw an exception if it returns false. So calling code gets no indication that something is wrong.

#68 and #73 as currently written are also subject to this bug.

I'll submit two PRs for this, one with only new tests that cover this case, and one with tests plus fix.


Originally posted by @mbaynton at zendframework/zend-ldap#75

@weierophinney
Copy link
Member Author

@heiglandreas current tests pass because they check that ldap_mod_add() is being passed null?!?

https://github.com/zendframework/zend-ldap/blob/0234654ce6c300d3e59f7ce752d2895a7e6e673a/test/OfflineTest.php#L200

That should never be. Please advise how you'd like to proceed. You've not approved of any changes to existing tests in the past.


Originally posted by @mbaynton at zendframework/zend-ldap#75 (comment)

@weierophinney
Copy link
Member Author

thanks for noting and raising that issue! And I'd rather see that ldap_mod_add behaves the same as all the other methods and tries to bind when no connection is available.

I'm not yet sure how to handle that test but I'll check that today. Perhaps adding a new test for the fixed (right) behaviour and mark the current test as incomplete or skipped.


Originally posted by @heiglandreas at zendframework/zend-ldap#75 (comment)

@weierophinney
Copy link
Member Author

updateAttributes and deleteAttributes are also affected fwiw. I have subclassed Zend\Ldap locally to fix this for me anyways for now as I'm unsure what an acceptable patch would look like due to the broken existing test and @heiglandreas has assigned this to him as well.


Originally posted by @mbaynton at zendframework/zend-ldap#75 (comment)

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

No branches or pull requests

1 participant