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

Commit c6c47ae

Browse filesBrowse files
committed
[Ldap] Allow search scoping
1 parent c3b9690 commit c6c47ae
Copy full SHA for c6c47ae

File tree

3 files changed

+46
-10
lines changed
Filter options

3 files changed

+46
-10
lines changed

‎src/Symfony/Component/Ldap/Adapter/AbstractQuery.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/AbstractQuery.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ public function __construct(ConnectionInterface $connection, $dn, $query, array
3434
'timeout' => 0,
3535
'deref' => static::DEREF_NEVER,
3636
'attrsOnly' => 0,
37+
'scope' => static::SCOPE_SUBTREE,
3738
));
3839
$resolver->setAllowedValues('deref', array(static::DEREF_ALWAYS, static::DEREF_NEVER, static::DEREF_FINDING, static::DEREF_SEARCHING));
40+
$resolver->setAllowedValues('scope', array(static::SCOPE_BASE, static::SCOPE_ONELEVEL, static::SCOPE_SUBTREE));
41+
3942
$resolver->setNormalizer('filter', function (Options $options, $value) {
4043
return is_array($value) ? $value : array($value);
4144
});

‎src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php
+39-10Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,45 @@ public function execute()
6060

6161
$con = $this->connection->getResource();
6262

63-
$this->search = @ldap_search(
64-
$con,
65-
$this->dn,
66-
$this->query,
67-
$this->options['filter'],
68-
$this->options['attrsOnly'],
69-
$this->options['maxItems'],
70-
$this->options['timeout'],
71-
$this->options['deref']
72-
);
63+
switch ($this->options['scope']) {
64+
case static::SCOPE_BASE:
65+
$this->search = @ldap_read(
66+
$con,
67+
$this->dn,
68+
$this->query,
69+
$this->options['filter'],
70+
$this->options['attrsOnly'],
71+
$this->options['maxItems'],
72+
$this->options['timeout'],
73+
$this->options['deref']
74+
);
75+
break;
76+
case static::SCOPE_ONELEVEL:
77+
$this->search = @ldap_list(
78+
$con,
79+
$this->dn,
80+
$this->query,
81+
$this->options['filter'],
82+
$this->options['attrsOnly'],
83+
$this->options['maxItems'],
84+
$this->options['timeout'],
85+
$this->options['deref']
86+
);
87+
break;
88+
case static::SCOPE_SUBTREE:
89+
default:
90+
$this->search = @ldap_search(
91+
$con,
92+
$this->dn,
93+
$this->query,
94+
$this->options['filter'],
95+
$this->options['attrsOnly'],
96+
$this->options['maxItems'],
97+
$this->options['timeout'],
98+
$this->options['deref']
99+
);
100+
break;
101+
}
73102
}
74103

75104
if (false === $this->search) {

‎src/Symfony/Component/Ldap/Adapter/QueryInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Adapter/QueryInterface.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ interface QueryInterface
2323
const DEREF_FINDING = 0x02;
2424
const DEREF_ALWAYS = 0x03;
2525

26+
const SCOPE_BASE = 0x00;
27+
const SCOPE_ONELEVEL = 0x01;
28+
const SCOPE_SUBTREE = 0x02;
29+
2630
/**
2731
* Executes a query and returns the list of Ldap entries.
2832
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.