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 /path/to/this/file
22 # perlModule SampleLDAP
24 # Note that "perlModulePath" is the directory path in which the perl module can be found
25 # not the path to the file. Please also see slapd-perl(5)
37 print STDERR "Here in new\n";
38 print STDERR "Posix Var " . BUFSIZ . " and " . FILENAME_MAX . "\n";
50 my($base, $scope, $deref, $sizeLim, $timeLim, $filterStr, $attrOnly, @attrs ) = @_;
51 print STDERR "====$filterStr====\n";
52 $filterStr =~ s/\(|\)//g;
53 $filterStr =~ s/=/: /;
56 foreach my $dn ( keys %$this ) {
57 if ( $this->{ $dn } =~ /$filterStr/im ) {
59 last if ( scalar @match_dn == $sizeLim );
64 my @match_entries = ();
66 foreach my $dn ( @match_dn ) {
67 push @match_entries, $this->{ $dn };
70 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
93 my ( $dn, @list ) = @_;
96 my $action = shift @list;
97 my $key = shift @list;
98 my $value = shift @list;
100 if( $action eq "ADD" ) {
101 $this->{ $dn } .= "$key: $value\n";
104 elsif( $action eq "DELETE" ) {
105 $this->{ $dn } =~ s/^$key:\s*$value\n//mi ;
108 elsif( $action eq "REPLACE" ) {
109 $this->{ $dn } =~ s/$key: .*$/$key: $value/im ;
120 my ( $entryStr ) = @_;
122 my ( $dn ) = ( $entryStr =~ /dn:\s(.*)$/m );
125 # This needs to be here until a normalized dn is
126 # passed to this routine.
132 $this->{$dn} = $entryStr;
141 my ( $dn, $newdn, $delFlag ) = @_;
143 $this->{ $newdn } = $this->{ $dn };
146 delete $this->{ $dn };
158 print STDERR "XXXXXX $dn XXXXXXX\n";