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.
70 * attribute assertion string
76 This method is called when a modify request comes from a client.
77 Its arguments are as follows.
81 * lists formatted as follows
82 { ADD | DELETE | REPLACE }, key, value
88 This method is called when a add request comes from a client.
89 Its arguments are as follows.
92 * entry in string format.
98 This method is called when a modrdn request comes from a client.
99 Its arguments are as follows.
104 * delete old dn flage ( 1 means yes )
110 This method is called when a delete request comes from a client.
111 Its arguments are as follows.
121 * arrray of arguments on line
123 RETURN: non zero value if this is not a valid option.
127 The perl section of the config file recognizes the following
128 options. It should also be noted that any option not recoginized
129 will be sent to the B<config> method of the perl module as noted
132 database perl # startn section for the perl database
134 suffix "o=AnyOrg, c=US"
136 perlModulePath /path/to/libs # addes the path to @INC variable same
137 # as "use lib '/path/to/libs'"
139 perlModule ModName # use the module name ModName from ModName.pm
155 print STDERR "Here in new\n";
156 print STDERR "Posix Var " . BUFSIZ . " and " . FILENAME_MAX . "\n";
163 my( $filterStr, $sizeLim, $timeLim, $attrOnly, @attrs ) = @_;
164 print STDERR "====$filterStr====\n";
165 $filterStr =~ s/\(|\)//g;
166 $filterStr =~ s/=/: /;
169 foreach my $dn ( keys %$this ) {
170 if ( $this->{ $dn } =~ /$filterStr/im ) {
172 last if ( scalar @match_dn == $sizeLim );
177 my @match_entries = ();
179 foreach my $dn ( @match_dn ) {
180 push @match_entries, $this->{ $dn };
183 return ( 0 , @match_entries );
190 my ( $dn, $avaStr ) = @_;
195 if ( $this->{ $dn } =~ /$avaStr/im ) {
206 my ( $dn, @list ) = @_;
208 while ( @list > 0 ) {
209 my $action = shift @list;
210 my $key = shift @list;
211 my $value = shift @list;
213 if( $action eq "ADD" ) {
214 $this->{ $dn } .= "$key: $value\n";
217 elsif( $action eq "DELETE" ) {
218 $this->{ $dn } =~ s/^$key:\s*$value\n//mi ;
221 elsif( $action eq "REPLACE" ) {
222 $this->{ $dn } =~ s/$key: .*$/$key: $value/im ;
233 my ( $entryStr ) = @_;
235 my ( $dn ) = ( $entryStr =~ /dn:\s(.*)$/m );
238 # This needs to be here untill a normalize dn is
239 # passed to this routine.
245 $this->{$dn} = $entryStr;
254 my ( $dn, $newdn, $delFlag ) = @_;
256 $this->{ $newdn } = $this->{ $dn };
259 delete $this->{ $dn };
271 print STDERR "XXXXXX $dn XXXXXXX\n";