# perldoc > Net::LDAP::Control::PersistentSearch

---
type: CommandReference
command: Net::LDAP::Control::PersistentSearch
mode: perldoc
section: 
source: perldoc
---

## Quick Reference

- `Net::LDAP::Control::PersistentSearch->new(changeTypes => 15, changesOnly => 1, returnECs => 1)` — create a persistent search control watching all changes, only returning changed entries with entry change notifications
- `$ldap->search(..., control => [$persist])` — attach control to a search operation
- `sub process_entry { my $message = shift; my $entry = shift; print $entry->dn(); $message->pop_entry() }` — callback invoked for each entry returned
- `changeTypes` bitmask: `1` = add, `2` = delete, `4` = modify, `8` = modDN

## Name

LDAPv3 Persistent Search control object

## Synopsis

perl
use Net::LDAP;
use Net::LDAP::Control::PersistentSearch;

$ldap = Net::LDAP->new("ldap.mydomain.eg");

$persist = Net::LDAP::Control::PersistentSearch->new(
    changeTypes => 15,
    changesOnly => 1,
    returnECs   => 1
);

$srch = $ldap->search(
    base     => "cn=People,dc=mydomain,dc=eg",
    filter   => "(objectClass=person)",
    callback => \&process_entry,
    control  => [ $persist ]
);

die "error: ", $srch->code(), ": ", $srch->error() if ($srch->code());

sub process_entry {
    my $message = shift;
    my $entry   = shift;
    print $entry->dn() . "\n";
    $message->pop_entry();
}
## Options (Constructor Arguments)

- `changeTypes` — integer bitwise OR of change types to watch: `1` (add), `2` (delete), `4` (modify), `8` (modDN). Defaults to `15` (all changes).
- `changesOnly` — boolean. If `TRUE`, the server returns only entries that change (add, delete, modify, modDN); existing entries that match the search criteria are not returned.
- `returnECs` — boolean. If `TRUE`, each entry returned by a change includes an Entry Change Notification control (see `Net::LDAP::Control::EntryChange`).

## Methods

Each constructor argument (`changeTypes`, `changesOnly`, `returnECs`) is also available as a method. Calling the method without an argument returns the current value; calling it with an argument sets a new value.

## Examples

See the Synopsis section above for a complete example.

## See Also

- [Net::LDAP](https://metacpan.org/pod/Net::LDAP)
- [Net::LDAP::Control](https://metacpan.org/pod/Net::LDAP::Control)
- [Net::LDAP::Control::EntryChange](https://metacpan.org/pod/Net::LDAP::Control::EntryChange)