1 # This is a sample Perl module for the OpenLDAP server slapd.
2 # $OpenLDAP: pkg/ldap/servers/slapd/back-perl/SampleLDAP.pm,v 1.10.2.3 2008/02/11 23:26:47 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## Portions Copyright 1999 John C. Quillan.
7 ## All rights reserved.
9 ## Redistribution and use in source and binary forms, with or without
10 ## modification, are permitted only as authorized by the OpenLDAP
13 ## A copy of this license is available in the file LICENSE in the
14 ## top-level directory of the distribution or, alternatively, at
15 ## <http://www.OpenLDAP.org/license.html>.
17 # Usage: Add something like this to slapd.conf:
20 # suffix "o=AnyOrg,c=US"
21 # perlModulePath /directory/containing/this/module
22 # perlModule SampleLDAP
24 # See the slapd-perl(5) manual page for details.
31 $SampleLDAP::VERSION
= '1.01';
38 print {*STDERR
} "Here in new\n";
39 print {*STDERR
} 'Posix Var ' . BUFSIZ
. ' and ' . FILENAME_MAX
. "\n";
49 my ( $base, $scope, $deref, $sizeLim, $timeLim, $filterStr, $attrOnly,
52 print {*STDERR
}, "====$filterStr====\n";
53 $filterStr =~ s/\(|\)//gm;
54 $filterStr =~ s/=/: /m;
57 for my $dn ( keys %{$this} ) {
58 if ( $this->{$dn} =~ /$filterStr/imx ) {
60 last if ( scalar @match_dn == $sizeLim );
65 my @match_entries = ();
67 for my $dn (@match_dn) {
68 push @match_entries, $this->{$dn};
71 return ( 0, @match_entries );
77 my ( $dn, $avaStr ) = @_;
78 my $rc = 5; # LDAP_COMPARE_FALSE
82 if ( $this->{$dn} =~ /$avaStr/im ) {
83 $rc = 6; # LDAP_COMPARE_TRUE
92 my ( $dn, @list ) = @_;
95 my $action = shift @list;
96 my $key = shift @list;
97 my $value = shift @list;
99 if ( $action eq 'ADD' ) {
100 $this->{$dn} .= "$key: $value\n";
103 elsif ( $action eq 'DELETE' ) {
104 $this->{$dn} =~ s/^$key:\s*$value\n//im;
107 elsif ( $action eq 'REPLACE' ) {
108 $this->{$dn} =~ s/$key: .*$/$key: $value/im;
120 my ($dn) = ( $entryStr =~ /dn:\s(.*)$/m );
123 # This needs to be here until a normalized dn is
124 # passed to this routine.
129 $this->{$dn} = $entryStr;
137 my ( $dn, $newdn, $delFlag ) = @_;
139 $this->{$newdn} = $this->{$dn};
153 print {*STDERR
} "XXXXXX $dn XXXXXXX\n";
163 print {*STDERR
} @args;
164 print {*STDERR
} "\n";