ENTRY(1)

NAME
Net::LDAP::Entry - An LDAP entry object

SYNOPSIS
  use Net::LDAP;
  $ldap = Net::LDAP->new($host);
  $mesg = $ldap->search(@search_args);
  my $max = $mesg->count;
  for($i = 0 ; $i < $max ; $i++) {
    my $entry = $mesg->entry($i);
    foreach my $attr ($entry->attributes) {
      print join("\n ",$attr, $entry->get_value($attr)),"\n";
    }
  }
  # or
  use Net::LDAP::Entry;
  $entry = Net::LDAP::Entry->new;
  $entry->add(
    attr1 => 'value1',
    attr2 => [qw(value1 value2)]
  );
  $entry->delete( 'unwanted' );
  $entry->replace(
    attr1 => 'newvalue'
    attr2 => [qw(new values)]
  );
  $entry->update( $ldap ); # update directory server

DESCRIPTION
The Net::LDAP::Entry object represents a single entry in the directory. It is a container for attribute-value pairs.

A Net::LDAP::Entry object can be used in two situations. The first and probably most common use is in the result of a search to the directory server.

The other is where a new object is created locally and then a single command is sent to the directory server to add, modify or replace an entry. Entries for this purpose can also be created by reading an LDIF file with the Net::LDAP::LDIF module.

CONSTRUCTOR
Create a new entry object with the changetype set to `'add''

METHODS
Add one or more new attributes to the entry. Each value must be a scalar variable or a reference to an array. The values given will be added to the values which already exist for the given attributes.

  $entry->add( 'sn' => 'Barr');
  $entry->add( 'street' => [ '1 some road','nowhere']);
NOTE: these changes are local to the client and will not appear on the directory server until the `update' method is called. Return a list of attributes that this entry has.

OPTIONS is a list of name/value pairs, valid options are :-
    If TRUE, return a list of the attribute names excluding any options. For example for the entry

      name: Graham Barr
      name;en-us: Bob
      jpeg;binary: **binary data**
    the return list would be `( 'name', 'jpeg' )'.
If called without arguments it returns the type of operation that would be performed when the update method is called. If called with an argument it will set the changetype to TYPE.

Possible values for TYPE are
    The update method will call the add method on the client object, which will result in the entry being added to the directory server. The update method will call the delete method on the client object, which will result in the entry being removed from the directory server. The update method will call the modify method on the client object, which will result in any changes that have been made locally being made to the entry on the directory server.
Delete the given attributes from the entry. If no attributes are passed then the next call to update will cause the entry to be deleted from the server.

NOTE: these changes are local to the client and will not appear on the directory server until the `update' method is called. Set or get the DN for the entry. With no arguments `dn' will return the current DN. If an argument is given then it will change the DN for the entry and return the previous value.

NOTE: these changes are local to the client and will not appear on the directory server until the `update' method is called. Returns TRUE if the entry has an attribute called ATTR. Get the values for the attribute ATTR. In a list context returns all values for the given attribute, or the empty list if the attribute does not exist. In a scalar context returns the first value for the attribute or undef if the attribute does not exist.

The return value may be changed by OPTIONS, which is a list of name => value pairs, valid options are :-
    If TRUE then the result will be a hash reference. The keys of the hash will be the options and the hash value will be the values for those attributes. For example if an entry had

      name: Graham Barr
      name;en-us: Bob
    Then a get for attribute "name" with alloptions set would return

      {
        ''       => [ 'Graham Barr' ],
        ';en-us' => [ 'Bob' ]
      }
    If TRUE then the result will be a reference to an array containing all the values for the attribute, or undef if the attribute does not exist.

    NOTE: In the interest of performance the array references returned by `get_value' are references to structures held inside the entry object. These values and thier contents should NOT be modified directly.
Similar to add, except that the values given will replace any values that already exist for the given attributes.

NOTE: these changes are local to the client and will not appear on the directory server until the `update' method is called. Update the directory server with any changes that have been made locally to the attributes of this entry. This means any calls that have been made to add, replace or delete since the last call to changetype or update was made.

This method cannot be used to modify the DN of the entry on the server, for that see the `moddn' method in Net::LDAP.

CLIENT is a `Net::LDAP' object where the update will be sent to.

The result will be an object of type Net::LDAP::Message as returned by the add, modify or delete method called on CLIENT.

SEE ALSO
Net::LDAP, Net::LDAP::LDIF

AUTHOR
Graham Barr <gbarr@pobox.com>.

Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap-dev@lists.sourceforge.net>.

COPYRIGHT
Copyright (c) 1997-2000 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

$Id$