$_options
$_options : array
Options.
LDIF capabilities for Horde_Ldap.
This class provides a means to convert between Horde_Ldap_Entry objects and LDAP entries represented in LDIF format files. Reading and writing are supported and manipulating of single entries or lists of entries.
Usage example:
// Read and parse an LDIF file into Horde_Ldap_Entry objects
// and print out the DNs. Store the entries for later use.
$entries = array();
$ldif = new Horde_Ldap_Ldif('test.ldif', 'r', $options);
do {
$entry = $ldif->readEntry();
$dn = $entry->dn();
echo " done building entry: $dn\n";
$entries[] = $entry;
} while (!$ldif->eof());
$ldif->done();
// Write those entries to another file $ldif = new Horde_Ldap_Ldif('test.out.ldif', 'w', $options); $ldif->writeEntry($entries); $ldif->done();
Copyright 2009 Benedikt Hallinger Copyright 2010-2017 Horde LLC (http://www.horde.org/)
__construct(string|\ressource $file, string $mode = 'r', array $options = array())
Constructor.
Opens an LDIF file for reading or writing.
$options is an associative array and may contain:
string|\ressource | $file | Filename or file handle. |
string | $mode | Mode to open the file, either 'r', 'w' or 'a'. |
array | $options | Options like described above. |
readEntry() : \Horde_Ldap_Entry
Reads one entry from the file and return it as a Horde_Ldap_Entry object.
writeEntry(\Horde_Ldap_Entry|array $entries)
Writes the entry or entries to the LDIF file.
If you want to build an LDIF file containing several entries AND you want to call writeEntry() several times, you must open the file handle in append mode ('a'), otherwise you will always get the last entry only.
\Horde_Ldap_Entry|array | $entries | Entry or array of entries. |
version(integer $version = null) : integer
Returns or sets the LDIF version.
If called with an argument it sets the LDIF version. According to RFC 2849 currently the only legal value for the version is 1.
integer | $version | LDIF version to set. |
The current or new version.
currentEntry() : \Horde_Ldap_Entry
Returns the current Horde_Ldap_Entry object.
parseLines(array $lines) : \Horde_Ldap_Entry
Parse LDIF lines of one entry into an Horde_Ldap_Entry object.
array | $lines | LDIF lines for one entry. |
Horde_Ldap_Entry object for those lines.
nextLines(boolean $force = false) : array
Returns the lines that will generate the next Horde_Ldap_Entry object.
If you set $force to true you can iterate over the lines that build up entries manually. Otherwise, iterating is done using {@link readEntry()}. $force will move the file pointer forward, thus returning the next entry lines.
Wrapped lines will be unwrapped. Comments are stripped.
boolean | $force | Set this to true if you want to iterate over the lines manually |
_changeEntry(\Horde_Ldap_Entry $entry)
Writes an LDIF file that describes an entry change.
\Horde_Ldap_Entry | $entry |
_writeEntry(\Horde_Ldap_Entry $entry)
Writes an LDIF file that describes an entry.
\Horde_Ldap_Entry | $entry |
_convertAttribute(string $attr_name, string $attr_value) : string
Converts an attribute and value to LDIF string representation.
It honors correct encoding of values according to RFC 2849. Line wrapping will occur at the configured maximum but only if the value is greater than 40 chars.
string | $attr_name | Name of the attribute. |
string | $attr_value | Value of the attribute. |
LDIF string for that attribute and value.