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-2005 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
34 print STDERR "Here in new\n";
35 print STDERR "Posix Var " . BUFSIZ . " and " . FILENAME_MAX . "\n";
47 my($base, $scope, $deref, $sizeLim, $timeLim, $filterStr, $attrOnly, @attrs ) = @_;
48 print STDERR "====$filterStr====\n";
49 $filterStr =~ s/\(|\)//g;
50 $filterStr =~ s/=/: /;
53 foreach my $dn ( keys %$this ) {
54 if ( $this->{ $dn } =~ /$filterStr/im ) {
56 last if ( scalar @match_dn == $sizeLim );
61 my @match_entries = ();
63 foreach my $dn ( @match_dn ) {
64 push @match_entries, $this->{ $dn };
67 return ( 0 , @match_entries );
74 my ( $dn, $avaStr ) = @_;
75 my $rc = 5; # LDAP_COMPARE_FALSE
79 if ( $this->{ $dn } =~ /$avaStr/im ) {
80 $rc = 6; # LDAP_COMPARE_TRUE
90 my ( $dn, @list ) = @_;
93 my $action = shift @list;
94 my $key = shift @list;
95 my $value = shift @list;
97 if( $action eq "ADD" ) {
98 $this->{ $dn } .= "$key: $value\n";
101 elsif( $action eq "DELETE" ) {
102 $this->{ $dn } =~ s/^$key:\s*$value\n//mi ;
105 elsif( $action eq "REPLACE" ) {
106 $this->{ $dn } =~ s/$key: .*$/$key: $value/im ;
117 my ( $entryStr ) = @_;
119 my ( $dn ) = ( $entryStr =~ /dn:\s(.*)$/m );
122 # This needs to be here until a normalized dn is
123 # passed to this routine.
129 $this->{$dn} = $entryStr;
138 my ( $dn, $newdn, $delFlag ) = @_;
140 $this->{ $newdn } = $this->{ $dn };
143 delete $this->{ $dn };
155 print STDERR "XXXXXX $dn XXXXXXX\n";