use Net::LDAP::Entry; use Net::LDAP::Filter; use Net::LDAP::FilterMatch; my $entry = new Net::LDAP::Entry; $entry->dn("cn=dummy entry"); $entry->add ( 'cn' => 'dummy entry', 'street' => [ '1 some road','nowhere' ] ); my @filters = (qw/(cn=dummy*) (ou=*) (&(cn=dummy*)(street=*road)) (&(cn=dummy*)(!(street=nowhere)))/); for (@filters) { my $filter = Net::LDAP::Filter->new($_); print $_,' : ', $filter->match($entry) ? 'match' : 'no match' ,"\n"; }
Given an entry it will tell whether the entry matches the filter object.
It can be used on its own or as part of a Net::LDAP::Server based LDAP server.
In case of error undef is returned.
For approximate matching like (cn~=Schmidt) there are several modules that can be used. By default the following modules will be tried in this order:
String::Approx Text::Metaphone Text::Soundex
If none of these modules is found it will fall back on a simple regexp algorithm.
If you want to specifically use one implementation only, simply do
use Net::LDAP::FilterMatch qw(Text::Soundex);