1 # This is a sample Perl module for the OpenLDAP server slapd.
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 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.
36 print STDERR "Here in new\n";
37 print STDERR "Posix Var " . BUFSIZ . " and " . FILENAME_MAX . "\n";
49 my($base, $scope, $deref, $sizeLim, $timeLim, $filterStr, $attrOnly, @attrs ) = @_;
50 print STDERR "====$filterStr====\n";
51 $filterStr =~ s/\(|\)//g;
52 $filterStr =~ s/=/: /;
55 foreach my $dn ( keys %$this ) {
56 if ( $this->{ $dn } =~ /$filterStr/im ) {
58 last if ( scalar @match_dn == $sizeLim );
63 my @match_entries = ();
65 foreach my $dn ( @match_dn ) {
66 push @match_entries, $this->{ $dn };
69 return ( 0 , @match_entries );
76 my ( $dn, $avaStr ) = @_;
77 my $rc = 5; # LDAP_COMPARE_FALSE
81 if ( $this->{ $dn } =~ /$avaStr/im ) {
82 $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//mi ;
107 elsif( $action eq "REPLACE" ) {
108 $this->{ $dn } =~ s/$key: .*$/$key: $value/im ;
119 my ( $entryStr ) = @_;
121 my ( $dn ) = ( $entryStr =~ /dn:\s(.*)$/m );
124 # This needs to be here until a normalized dn is
125 # passed to this routine.
131 $this->{$dn} = $entryStr;
140 my ( $dn, $newdn, $delFlag ) = @_;
142 $this->{ $newdn } = $this->{ $dn };
145 delete $this->{ $dn };
157 print STDERR "XXXXXX $dn XXXXXXX\n";