VERSION

version 0.03

NAME

Net::LDAP::Filter::SQL - LDAP filter to SQL clause transformer

SYNOPSIS

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)

DESCRIPTION

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.

METHODS

new( ldapfilter )

Create a new LDAP Filter

new_from_data( $hashref )

Creates a new LDAP Filter from an existing data set. i.e. a Net::LDAP::Filter structure

sql_clause()

returns an sql where clause in string format with '?' placeholders

sql_values()

returns a list of values associated with the filter

METHODS

EXAMPLE

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'
#                       ]
#         };

BUGS

probably lots, please send patches

TODO

Figure out what to do with approxMatch. From RFC 4511 (http://www.faqs.org/rfcs/rfc4511.html):

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.

SUPPORT

send me an e-mail

SEE ALSO

ACKNOWLEDGEMENTS

My mother, for raising me and my brother the way she did. Thanks mom!

INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

BUGS AND LIMITATIONS

You can make new bug reports, and view existing ones, through the web interface at http://rt.cpan.org.

AUTHOR

Tim Esselens <tim.esselens@gmail.com>

COPYRIGHT AND LICENSE

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.