4 This is a sample Perl module for the OpenLDAP server slapd.
5 It also contains the documentation that you will need to
8 WARNING: the interfaces of this backen to the perl module
9 MAY change. Any suggestions would greatly be appreciated.
14 The Perl back end works by embedding a Perl interpreter into
15 the slapd backend. Then when the configuration file indicates
16 that we are going to be using a Perl backend it will get an
17 option that tells it what module to use. It then creates a
18 new Perl object that handles all the request for that particular
19 instance of the back end.
24 You will need to create a method for each one of the
25 following actions that you wish to handle.
27 * new # Creates a new object.
28 * search # Performs the ldap search
29 * compare # does a compare
30 * modify # modify's and entry
31 * add # adds an entry to back end
32 * modrdn # modifies a an entries rdn
33 * delete # deletes an ldap entry
34 * config # process unknow config file lines
38 This method is called when the config file encounters a
39 B<perlmod> line. The module in that line is then effectively
40 used into the perl interpreter, then the new method is called
41 to create a new object. Note that multiple instances of that
42 object may be instantiated, as with any perl object.
44 The new method doesn't receive any arguments other than the
51 This method is called when a search request comes from a client.
52 It arguments are as follow.
58 * attributes only flag ( 1 for yes )
59 * list of attributes that are to be returned. (could be empty)
65 This method is called when a compare request comes from a client.
66 Its arguments are as follows.
75 This method is called when a modify request comes from a client.
76 Its arguments are as follows.
80 * lists formatted as follows
81 { ADD | DELETE | REPLACE }, key, value
87 This method is called when a add request comes from a client.
88 Its arguments are as follows.
91 * entry in string format.
97 This method is called when a modrdn request comes from a client.
98 Its arguments are as follows.
103 * delete old dn flage ( 1 means yes )
109 This method is called when a delete request comes from a client.
110 Its arguments are as follows.
120 * arrray of arguments on line
122 RETURN: non zero value if this is not a valid option.
126 The perl section of the config file recognizes the following
127 options. It should also be noted that any option not recoginized
128 will be sent to the B<config> method of the perl module as noted
131 database perl # startn section for the perl database
133 suffix "o=AnyOrg, c=US"
135 perlModulePath /path/to/libs # addes the path to @INC variable same
136 # as "use lib '/path/to/libs'"
138 perlModule ModName # use the module name ModName from ModName.pm
154 print STDERR "Here in new\n";
155 print STDERR "Posix Var " . BUFSIZ . " and " . FILENAME_MAX . "\n";
162 my( $filterStr, $sizeLim, $timeLim, $attrOnly, @attrs ) = @_;
163 print STDERR "====$filterStr====\n";
164 $filterStr =~ s/\(|\)//g;
165 $filterStr =~ s/=/: /;
168 foreach my $dn ( keys %$this ) {
169 if ( $this->{ $dn } =~ /$filterStr/im ) {
171 last if ( scalar @match_dn == $sizeLim );
176 my @match_entries = ();
178 foreach my $dn ( @match_dn ) {
179 push @match_entries, $this->{ $dn };
182 return ( 0 , @match_entries );
198 my ( $dn, @list ) = @_;
200 while ( @list > 0 ) {
201 my $action = shift @list;
202 my $key = shift @list;
203 my $value = shift @list;
205 if( $action eq "ADD" ) {
206 $this->{ $dn } .= "$key: $value\n";
209 elsif( $action eq "DELETE" ) {
210 $this->{ $dn } =~ s/^$key:\s*$value\n//mi ;
213 elsif( $action eq "REPLACE" ) {
214 $this->{ $dn } =~ s/$key: .*$/$key: $value/im ;
225 my ( $entryStr ) = @_;
227 my ( $dn ) = ( $entryStr =~ /dn:\s(.*)$/m );
230 # This needs to be here untill a normalize dn is
231 # passed to this routine.
237 $this->{$dn} = $entryStr;
246 my ( $dn, $newdn, $delFlag ) = @_;
248 $this->{ $newdn } = $this->{ $dn };
251 delete $this->{ $dn };
263 print STDERR "XXXXXX $dn XXXXXXX\n";