11
11
12
12
namespace Symfony \Component \Ldap \Adapter \ExtLdap ;
13
13
14
- use LDAP \Connection as LDAPConnection ;
15
14
use LDAP \Result ;
16
15
use Symfony \Component \Ldap \Adapter \AbstractQuery ;
17
16
use Symfony \Component \Ldap \Adapter \CollectionInterface ;
@@ -26,7 +25,7 @@ class Query extends AbstractQuery
26
25
{
27
26
public const PAGINATION_OID = \LDAP_CONTROL_PAGEDRESULTS ;
28
27
29
- /** @var resource[]| Result[] */
28
+ /** @var Result[] */
30
29
private array $ results ;
31
30
32
31
private array $ serverctrls = [];
@@ -99,7 +98,7 @@ public function execute(): CollectionInterface
99
98
if ($ pageSize > 0 && $ sizeLimit >= $ pageSize ) {
100
99
$ sizeLimit = 0 ;
101
100
}
102
- $ search = $ this ->callSearchFunction ( $ con , $ func , $ sizeLimit );
101
+ $ search = @ $ func ( $ con , $ this ->dn , $ this -> query , $ this -> options [ ' filter ' ] , $ this -> options [ ' attrsOnly ' ], $ sizeLimit, $ this -> options [ ' timeout ' ], $ this -> options [ ' deref ' ], $ this -> serverctrls );
103
102
104
103
if (false === $ search ) {
105
104
$ ldapError = '' ;
@@ -120,7 +119,9 @@ public function execute(): CollectionInterface
120
119
break ;
121
120
}
122
121
if ($ pageControl ) {
123
- $ cookie = $ this ->controlPagedResultResponse ($ con , $ search );
122
+ ldap_parse_result ($ con , $ search , $ errcode , $ matcheddn , $ errmsg , $ referrals , $ controls );
123
+
124
+ $ cookie = $ controls [\LDAP_CONTROL_PAGEDRESULTS ]['value ' ]['cookie ' ] ?? '' ;
124
125
}
125
126
} while (null !== $ cookie && '' !== $ cookie );
126
127
@@ -136,19 +137,17 @@ public function execute(): CollectionInterface
136
137
* Returns an LDAP search resource. If this query resulted in multiple searches, only the first
137
138
* page will be returned.
138
139
*
139
- * @return resource|Result|null
140
- *
141
140
* @internal
142
141
*/
143
- public function getResource (int $ idx = 0 )
142
+ public function getResource (int $ idx = 0 ): ? Result
144
143
{
145
144
return $ this ->results [$ idx ] ?? null ;
146
145
}
147
146
148
147
/**
149
148
* Returns all LDAP search resources.
150
149
*
151
- * @return resource[]| Result[]
150
+ * @return Result[]
152
151
*
153
152
* @internal
154
153
*/
@@ -206,29 +205,4 @@ private function controlPagedResult(int $pageSize, bool $critical, string $cooki
206
205
207
206
return true ;
208
207
}
209
-
210
- /**
211
- * Retrieve LDAP pagination cookie.
212
- *
213
- * @param resource|LDAPConnection $con
214
- * @param resource|Result $result
215
- */
216
- private function controlPagedResultResponse ($ con , $ result ): string
217
- {
218
- ldap_parse_result ($ con , $ result , $ errcode , $ matcheddn , $ errmsg , $ referrals , $ controls );
219
-
220
- return $ controls [\LDAP_CONTROL_PAGEDRESULTS ]['value ' ]['cookie ' ] ?? '' ;
221
- }
222
-
223
- /**
224
- * Calls actual LDAP search function with the prepared options and parameters.
225
- *
226
- * @param resource|LDAPConnection $con
227
- *
228
- * @return resource|Result|false
229
- */
230
- private function callSearchFunction ($ con , callable $ func , int $ sizeLimit )
231
- {
232
- return @$ func ($ con , $ this ->dn , $ this ->query , $ this ->options ['filter ' ], $ this ->options ['attrsOnly ' ], $ sizeLimit , $ this ->options ['timeout ' ], $ this ->options ['deref ' ], $ this ->serverctrls );
233
- }
234
208
}
0 commit comments