Projet

Général

Profil

Révision 59ae487e

Ajouté par Assos Assos il y a presque 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ldap/ldap_test/LdapServerTest.class.php
47 47
  }
48 48

  
49 49
  public function refreshFakeData() {
50
   // debug("refreshFakeData sid=". $this->sid);
51 50
    $test_data = variable_get('ldap_test_server__' . $this->sid, array());
52 51
    $this->methodResponses = (is_array($test_data) && isset($test_data['methodResponses'])) ? $test_data['methodResponses'] : array();
53 52
    $this->entries = (is_array($test_data) && isset($test_data['ldap'])) ? $test_data['ldap'] : array();
54
  //  debug('this->entries');debug($this->entries);
55 53
    $this->searchResults = (isset($test_data['search_results'])) ? $test_data['search_results'] : array();
56 54
    $this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
57 55
    foreach ($test_data['properties'] as $property_name => $property_value ) {
......
139 137
   */
140 138
  function search($base_dn = NULL, $filter, $attributes = array(), $attrsonly = 0, $sizelimit = 0, $timelimit = 0, $deref = LDAP_DEREF_NEVER, $scope = LDAP_SCOPE_SUBTREE) {
141 139

  
142
   // debug("ldap test server search base_dn=$base_dn, filter=$filter");
143

  
144 140
    $lcase_attribute = array();
145 141
    foreach ($attributes as $i => $attribute_name) {
146 142
      $lcase_attribute[] = drupal_strtolower($attribute_name);
......
154 150
        $base_dn = $this->basedn[0];
155 151
      }
156 152
      else {
157
        // debug("fail basedn: ldap test server search base_dn=$base_dn, filter=$filter");
158 153
        return FALSE;
159 154
      }
160 155
    }
......
164 159
     * are prepolulated in test data
165 160
     */
166 161
    if (isset($this->searchResults[$filter][$base_dn])) {
167
   //   debug("case1 filter= $filter   base_dn=$base_dn ");
168 162
      $results = $this->searchResults[$filter][$base_dn];
169 163
      foreach ($results as $i => $entry) {
170 164
        if (is_array($entry) && isset($entry['FULLENTRY'])) {
......
174 168
          $results[$i]['dn'] = $dn;
175 169
        }
176 170
      }
177
   //   debug($results);
178
      return $results; 
171
      return $results;
179 172
    }
180 173

  
181 174
    /**
......
188 181
    $operand = FALSE;
189 182

  
190 183
    if (strpos($filter, '&') === 0) {
191
   //   debug('2.A.');
192 184
     /**
193 185
     * case 2.A.: filter of form (&(<attribute>=<value>)(<attribute>=<value>)(<attribute>=<value>))
194 186
     *  such as (&(samaccountname=hpotter)(samaccountname=hpotter)(samaccountname=hpotter))
......
202 194
      }
203 195
    }
204 196
    elseif (strpos($filter, '|') === 0) {
205
      //debug('2.B.');
206 197
     /**
207 198
     * case 2.B: filter of form (|(<attribute>=<value>)(<attribute>=<value>)(<attribute>=<value>))
208 199
     *  such as (|(samaccountname=hpotter)(samaccountname=hpotter)(samaccountname=hpotter))
......
215 206
      foreach ($parts as $i => $pair) {
216 207
        $subqueries[] = explode('=', $pair);
217 208
      }
218
         // debug("operand=$operand, filter=$filter subqueries"); debug($subqueries);
219
   // debug($this->entries['cn=hpotter,ou=people,dc=hogwarts,dc=edu']);
220
   // debug($this->entries['cn=clone0,ou=people,dc=hogwarts,dc=edu']);
221 209
    }
222 210
    elseif (count(explode('=', $filter)) == 2) {
223
     // debug('2.C.');
224 211
     /**
225 212
     * case 2.C.: filter of form (<attribute>=<value>)
226 213
     *  such as (samaccountname=hpotter)
......
229 216
      $subqueries[] = explode('=', $filter);
230 217
    }
231 218
    else {
232
    //  debug('no case');
233 219
      return FALSE;
234 220
    }
235 221

  
......
243 229
      foreach ($subqueries as $i => $subquery) {
244 230
        $filter_attribute = drupal_strtolower($subquery[0]);
245 231
        $filter_value = $subquery[1];
246
      //  debug("filter_attribute=$filter_attribute, filter_value=$filter_value");
247 232
        foreach ($this->entries as $dn => $entry) {
248 233
          $dn_lcase = drupal_strtolower($dn);
249 234

  
......
254 239
          //$pos = strpos($dn_lcase, $base_dn);
255 240
          $substring = strrev(substr(strrev($dn_lcase), 0, strlen($base_dn)));
256 241
          $cascmp =  strcasecmp($base_dn, $substring);
257
          //debug("dn_lcase=$dn_lcase, base_dn=$base_dn,pos=$pos,substring=$substring,cascmp=$cascmp");
258 242
          if ($cascmp !== 0) {
259 243

  
260 244
            continue; // not in basedn
......
267 251
              break;
268 252
            }
269 253
          }
270
         // debug("filter value=$filter_value, attr_value_to_compare="); debug($attr_value_to_compare);
271 254
          if (!$attr_value_to_compare || drupal_strtolower($attr_value_to_compare[0]) != $filter_value) {
272 255
            continue;
273 256
          }
274 257

  
275 258
          // match!
276
         // debug("match"); debug($attr_value); debug($attributes);
277 259
          $entry['dn'] = $dn;
278 260
          if ($attributes) {
279 261
            $selected_data = array();
......
298 280

  
299 281
          $substring = strrev(substr(strrev($dn_lcase), 0, strlen($base_dn)));
300 282
          $cascmp =  strcasecmp($base_dn, $substring);
301
          //debug("dn_lcase=$dn_lcase, base_dn=$base_dn,pos=$pos,substring=$substring,cascmp=$cascmp");
302 283
          if ($cascmp !== 0) {
303 284
            $match = FALSE;
304 285
            break; // not in basedn
......
311 292
              break;
312 293
            }
313 294
          }
314
         // debug("filter value=$filter_value, attr_value_to_compare="); debug($attr_value_to_compare);
315 295
          if (!$attr_value_to_compare || drupal_strtolower($attr_value_to_compare[0]) != $filter_value) {
316 296
            $match = FALSE;
317 297
            break; // not in basedn
......
335 315
    }
336 316

  
337 317
    $results['count'] = count($results);
338
  //  debug("ldap test server search results"); debug($results);
339 318
    return $results;
340 319
  }
341 320

  
......
354 333
      $match = (strcasecmp($entry_dn, $find_dn) == 0);
355 334

  
356 335
      if ($match) {
357
      //  debug("testserver:dnExists,match=$match, entry_dn=$entry_dn, find_dn=$find_dn"); debug($entry);
358 336
        return ($return == 'boolean') ? TRUE : $entry;
359 337
      }
360 338
    }
361
   // debug("testserver:dnExists, no match");
362 339
    return FALSE; // not match found in loop
363 340

  
364 341
  }
......
458 435

  
459 436
    $test_data['entries'][$dn] = $ldap_entry;
460 437
    $test_data['ldap'][$dn] = $ldap_entry;
461
  //  debug("modifyLdapEntry:server test data before save $dn"); debug($test_data['entries'][$dn]);
462 438
    variable_set('ldap_test_server__' . $this->sid, $test_data);
463 439
    $this->refreshFakeData();
464 440
    return TRUE;
......
476 452
  public function delete($dn) {
477 453

  
478 454
    $test_data = variable_get('ldap_test_server__' . $this->sid, array());
479
   // debug("test ldap server, delete=$dn, test data="); debug(array_keys($test_data['users']));
480 455
    $deleted = FALSE;
481 456
    foreach (array('entries', 'users', 'groups', 'ldap') as $test_data_sub_array) {
482 457
      if (isset($test_data[$test_data_sub_array][$dn])) {

Formats disponibles : Unified diff