Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Ldap] Allow search scoping#20310
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
xunto commentedOct 27, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I need to further tell that without this change ldap is almost unusable in some cases. For example, to build a tree of departments, you need to search in SCOPE_ONELEVEL but you can't (without this PR). My dirty workaround is to look at length of entry's dn to understand if this is sub-department (cn is uuid, so it has fixed size). This is very dirty and unreliable solution. |
xunto commentedNov 1, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Why does nobody look at this PR (it's week already)?@csarrazi marked as author inhttps://github.com/symfony/ldap. Should I contact him? |
csarrazi commentedNov 1, 2016
@xunto I do not receive notifications unless I am explicitly tagged in a comment. |
csarrazi left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Just change the constant values to strings instead of integers, and this is LGTM. I've considered doing this a while ago, but it got out of my mind. Thanks@xunto!
| constDEREF_FINDING =0x02; | ||
| constDEREF_ALWAYS =0x03; | ||
| constSCOPE_BASE =0x00; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Do not use integer constants here unless they are actually part of the specification. Here, please use string values.
I.e.
constSCOPE_BASE ='base';constSCOPE_ONELEVEL ='one_level';constSCOPE_SUBTREE ='subtree';
csarrazi commentedNov 1, 2016
One thing though, please also add functional tests for the scope handling. |
| $func ='ldap_list'; | ||
| break; | ||
| casestatic::SCOPE_SUBTREE: | ||
| default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The default should actually throw an exception (which should actually never be thrown, as the OptionsResolver is actually the one which sanitizes thescope option) instead of being a fall-through for thesubtree scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@csarrazi actually I already defined allowed values in option OptionsResolver (c6c47ae#diff-822ec15d626e08f71c9ebaea383b5a89R40). So default is only for linter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Okay. So throw an exception in the default, and set $func to ldap_search in the SCOPE_SUBTREE case. :)
| 'scope' => Query::SCOPE_SUBTREE, | ||
| ))->execute()->count(); | ||
| $this->assertNotEquals($one_level,$subtree); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I do not feel that this tests anything useful (Apart from checking that a one level scope is different from a subtree). We should actually check whether we have the expected content in the output from the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm working on it right now)
| dn: cn=Scope,cn=Ldap,ou=Components,dc=symfony,dc=com | ||
| objectclass: organizationalunit | ||
| cn: Scopes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Add newline to end of file.
xunto commentedNov 2, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I apologise for big amount of commits. My distro have different paths for openldap so I can't run tests on my computer. |
csarrazi commentedNov 2, 2016
@xunto No problem, as long as you squash everything later! ;) You could also use thecsarrazi/symfony-ldap docker repository, if you want to easily spawn an openldap instance, btw! |
xunto commentedNov 2, 2016
@csarrazi Everything should be ok now. Thanks for review. I going to squash it right now. |
csarrazi commentedNov 2, 2016
You're welcome! |
xunto commentedNov 2, 2016
@csarrazi done |
xunto commentedNov 2, 2016
Oh, didn't noticed yout anwser about default in switch/case. Give me a minute... |
xunto commentedNov 2, 2016
@csarrazi Everything is done. Tests pass. |
csarrazi commentedNov 2, 2016
👍 |
xunto commentedNov 3, 2016
@csarrazi Should I slap deciders or mergers now? |
csarrazi commentedNov 3, 2016
Yup! :) |
xunto commentedNov 3, 2016
@csarrazi Thanks for help! @symfony/deciders, it's your turn! |
fabpot commentedNov 3, 2016
Just for your information, this new feature won't be merged for 3.2, but considered for 3.3. |
xunto commentedNov 3, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@fabpot Sad but ok, I think. So it won't get into the master until 3.2 is released? So, in december. |
fabpot commentedNov 3, 2016
Right, that's correct. |
xabbuh commentedNov 5, 2016
👍 |
csarrazi commentedNov 13, 2016
Hey@xunto! Sorry for getting back one more time. Could you just amend your PR and change the scope names so they respect RFC 2255? ("base" / "one" / "sub"). Seehttps://tools.ietf.org/html/rfc2255
That would be great! :) |
xunto commentedNov 14, 2016
@csarrazi Ok, will do. |
xunto commentedNov 15, 2016
@csarrazi done. |
xunto commentedDec 2, 2016
@symfony/deciders, 3.2 is released. Looks like now we can merge this. |
fabpot commentedDec 4, 2016
Thank you@xunto. |
This PR was squashed before being merged into the 3.3-dev branch (closes#20310).Discussion----------[Ldap] Allow search scoping| Q | A || --- | --- || Branch? | "master" || Bug fix? | no || New feature? | yes || BC breaks? | no || Deprecations? | no || Tests pass? | yes || Fixed tickets | - || License | MIT || Doc PR | - |Quite trivial, PR adds "scope" attribute to the query options. For example:```php public function ldapAction() { $ldap = $this->get("app.ldap"); $dn = $this->getParameter("dn"); $results = $ldap->query($dn, "(objectClass=*)", [ "scope" => Query::SCOPE_ONELEVEL ])->execute(); foreach ($results as $entry) { var_dump($entry->getDn()); echo "<br/>"; } return new Response(""); }```SCOPE_BASE:http://php.net/manual/ru/function.ldap-read.phpSCOPE_ONELEVEL:http://php.net/manual/ru/function.ldap-list.phpSCOPE_SUBTREE:http://php.net/manual/ru/function.ldap-search.phpCommits-------83c7915 [Ldap] Allow search scoping
Uh oh!
There was an error while loading.Please reload this page.
Quite trivial, PR adds "scope" attribute to the query options. For example:
SCOPE_BASE:http://php.net/manual/ru/function.ldap-read.php
SCOPE_ONELEVEL:http://php.net/manual/ru/function.ldap-list.php
SCOPE_SUBTREE:http://php.net/manual/ru/function.ldap-search.php