The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

VERSION

version 0.02

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 approxMatch should do. e.g. soundex?

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

No bugs have been reported.

Please report any bugs or feature requests through the web interface at http://rt.cpan.org.

AUTHOR

Tim Esselens <tim.esselens@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 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.