version 0.03
Net::LDAP::Filter::SQL - LDAP filter to SQL clause transformer
my $ldapfilter = new Net::LDAP::Filter( '(&(name=Homer)(city=Springfield))' ); my $sqlfilter = new Net::LDAP::Filter::SQL( '(&(name=Marge)(city=Springfield))' ); my $sqlfilter2 = Net::LDAP::Filter::SQL->new_from_data({ 'equalityMatch' => { 'assertionValue' => 'bar', 'attributeDesc' => 'foo' } }); my $sqlfilter3 = bless($ldapfilter,'Net::LDAP::Filter::SQL'); print Data::Dumper({ clause => $sqlfilter->sql_clause, values => $sqlfilter->sql_values }); # ... $dbh->selectall_arrayref('select * from sometable where '.$sqlfilter->sql_clause, undef, $sqlfilter->sql_values)
This module allows you to transform a Net::LDAP::Filter object into an SQL clause string containing '?' placeholders. The corresponding values can be accessed as a list, and thus can be used inside a dbh prepare or select call.
Create a new LDAP Filter
Creates a new LDAP Filter from an existing data set. i.e. a Net::LDAP::Filter structure
returns an sql where clause in string format with '?' placeholders
returns a list of values associated with the filter
my $filter = new Net::LDAP::Filter::SQL('(&(name=Marge)(city=Springfield))'); print Dumper({ clause => $filter->sql_clause, values => $filter->sql_values }); # $VAR1 = { # 'clause' => '(name = ?) and (city = ?)', # 'values' => [ # 'Marge', # 'Springfield' # ] # };
probably lots, please send patches
Figure out what to do with approxMatch. From RFC 4511 (http://www.faqs.org/rfcs/rfc4511.html):
approxMatch
4.5.1.7.6. SearchRequest.filter.approxMatch An approxMatch filter is TRUE when there is a value of the attribute type or subtype for which some locally-defined approximate matching algorithm (e.g., spelling variations, phonetic match, etc.) returns TRUE. If a value matches for equality, it also satisfies an approximate match. If approximate matching is not supported for the attribute, this filter item should be treated as an equalityMatch.
That's it: whatever you want it to be. Regex, soundex, etc.. or simply make it like an equalityMatch.
equalityMatch
send me an e-mail
Net::LDAP::Filter
Net::LDAP::Server
My mother, for raising me and my brother the way she did. Thanks mom!
See perlmodinstall for information and options on installing Perl modules.
You can make new bug reports, and view existing ones, through the web interface at http://rt.cpan.org.
Tim Esselens <tim.esselens@gmail.com>
This software is copyright (c) 2013 by Tim Esselens.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::LDAP::Filter::SQL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::LDAP::Filter::SQL
CPAN shell
perl -MCPAN -e shell install Net::LDAP::Filter::SQL
For more information on module installation, please visit the detailed CPAN module installation guide.