Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Ldap] Always have a valid connection when using the EntryManager #20605

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

Closed
wants to merge 3 commits into from

Conversation

bobvandevijver
Copy link
Contributor

Q A
Branch? 3.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? They should
Fixed tickets
License MIT
Doc PR

The connection might be null when calling the getEntryManager function as it uses the $this->connection instead of retrieved it from it's own method which checks (and constructs if necessary) it first.

@xabbuh
Copy link
Member

xabbuh commented Nov 24, 2016

Can we cover this with test?

@bobvandevijver
Copy link
Contributor Author

With some new insight from my side, we can say that you need to be bound to the LDAP-server (anonymous) before you can do anything with the EntryManager or the Query. This is solved in the Query class with an automatic anonymous bind if the connection is not yet bound, but the EntryManager ignores that.

That means that this PR is not yet complete: we also need some automatic binding in the EntryManager for when the connection is not yet bound. Note that it is uncommon to edit entries with an anonymous bind, so the use case is small.

In conclusion: the current Symfony source it works when you manually bind first, this PR does not fix the problem (yet).

@nicolas-grekas nicolas-grekas modified the milestones: 3.x, 3.2 Dec 6, 2016
@nicolas-grekas nicolas-grekas changed the title Always have a valid connection when using the EntryManager [Ldap] Always have a valid connection when using the EntryManager Dec 8, 2016
@nicolas-grekas
Copy link
Member

ping @csarrazi

Copy link
Contributor

@csarrazi csarrazi left a comment

Choose a reason for hiding this comment

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

👍

@fabpot
Copy link
Member

fabpot commented Dec 13, 2016

should be merged in 3.1, right?

@csarrazi
Copy link
Contributor

csarrazi commented Dec 13, 2016

Regarding @bobvandevijver's comment, I'm against having an auto-bind mechanism. The Ldap and Connection classes should not be aware of the user it is currently bound to, nor should they actually bind to the server without the user explicitly using the Ldap::bind() method.

If by "binding" you mean using an anonymous bind, then I agree that we need to run the Ldap::bind() method after getting the connection, or throw an exception if the user is not bound.

Another way of solving this problem is simply to throw an exception if the connection object is not initialised, or if the connection is not bound already, which actually would be more secure.

@csarrazi
Copy link
Contributor

Wait @fabpot we still have things to discuss. I would actually prefer this to throw an exception instead of trying to connect automatically. Same thing if the connection is not bound.

This will be more secure, especially since I want to prevent any auto-bind or auto-connecting logic from being inserted in the code. In my opinion, the bind or connection should be explicit, and done beforehand.

@bobvandevijver
Copy link
Contributor Author

I agree with @csarrazi, so I will try to update this PR with the exceptions this week.

@bobvandevijver
Copy link
Contributor Author

bobvandevijver commented Dec 18, 2016

I've updated the code to throw exceptions when a query or any data-edit is tried without binding the connection first. Also added some test to verify if the exception is thrown when the connection is not bound. I guess it should now have the functionality @csarrazi proposed.

With c87c3fd Travis failed on a single run related to the HttpKernel (line 3504), so I expect that same error for the pending one. It is however not related to this PR.

Edit: Indeed, again a fail on the HTTP-kernel (line 3496 this time).

@csarrazi
Copy link
Contributor

👍

@nicolas-grekas
Copy link
Member

👍

Status: reviewed

@fabpot
Copy link
Member

fabpot commented Jan 12, 2017

Thank you @bobvandevijver.

fabpot added a commit that referenced this pull request Jan 12, 2017
…Manager (bobvandevijver)

This PR was submitted for the 3.2 branch but it was merged into the 3.1 branch instead (closes #20605).

Discussion
----------

[Ldap] Always have a valid connection when using the EntryManager

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | They should
| Fixed tickets |
| License       | MIT
| Doc PR        |

The connection might be `null` when calling the `getEntryManager` function as it uses the `$this->connection` instead of retrieved it from it's own method which checks (and constructs if necessary) it first.

Commits
-------

7775ec2 [Ldap] Always have a valid connection when using the EntryManager
@fabpot fabpot closed this Jan 12, 2017
This was referenced Jan 12, 2017
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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.