You are here

public static function SimpleLdap::clean in Simple LDAP 7.2

Same name and namespace in other branches
  1. 7 SimpleLdap.class.php \SimpleLdap::clean()

Cleans up an array returned by the ldap_* functions.

@throw SimpleLdapException

Parameters

array $entry: An LDAP entry as returned by SimpleLdapServer::search()

Return value

array A scrubbed array, with all of the "extra crud" removed.

6 calls to SimpleLdap::clean()
SimpleLdapSchema::load in ./SimpleLdapSchema.class.php
Load the schema.
SimpleLdapServer::delete in ./SimpleLdapServer.class.php
Delete an entry from the directory.
SimpleLdapServer::rootdse in ./SimpleLdapServer.class.php
Loads the server's rootDSE.
SimpleLdapSSO::getHashedSid in simple_ldap_sso/SimpleLdapSSO.class.php
The hashed sid, as stored on LDAP.
SimpleLdapUserMassImportExportTestCase::testImport in simple_ldap_user/simple_ldap_user.test
Test mass import.

... See full list

File

./SimpleLdap.class.php, line 23
Class defining base Simple LDAP functionallity.

Class

SimpleLdap
Simple LDAP class.

Code

public static function clean($entry) {
  if (!is_array($entry)) {
    throw new SimpleLdapException('Can only clean an array.');
  }
  $clean = array();

  // Yes, this is ugly, but so are the ldap_*() results.
  for ($i = 0; $i < $entry['count']; $i++) {
    $clean[$entry[$i]['dn']] = array();
    for ($j = 0; $j < $entry[$i]['count']; $j++) {
      $clean[$entry[$i]['dn']][$entry[$i][$j]] = array();
      for ($k = 0; $k < $entry[$i][$entry[$i][$j]]['count']; $k++) {
        $clean[$entry[$i]['dn']][$entry[$i][$j]][] = $entry[$i][$entry[$i][$j]][$k];
      }
    }
  }
  return $clean;
}