/[A3C]/lib/A3C/LDAP.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/A3C/LDAP.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 106 by dpavlin, Thu May 1 17:06:02 2008 UTC revision 181 by dpavlin, Mon Jun 16 20:08:28 2008 UTC
# Line 6  use warnings; Line 6  use warnings;
6  use Net::LDAP;  use Net::LDAP;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8  use base qw(Jifty::Object Class::Accessor::Fast);  use base qw(Jifty::Object Class::Accessor::Fast);
9    use Jifty;
10  our @config_fields = keys %{ Jifty->config->app('LDAP') };  our @config_fields = keys %{ Jifty->config->app('LDAP') };
11  Jifty->log->debug("using fields from configuration: ",dump( @config_fields ));  Jifty->log->debug("using fields from configuration: ",dump( @config_fields ));
12  __PACKAGE__->mk_accessors( qw(ldap current_search), @config_fields );  __PACKAGE__->mk_accessors( qw(ldap current_search), @config_fields );
# Line 162  sub collection { Line 163  sub collection {
163    
164          while ( my $entry = $self->next ) {          while ( my $entry = $self->next ) {
165                  my $model_obj = Jifty->app_class('Model',$model)->new;                  my $model_obj = Jifty->app_class('Model',$model)->new;
                 #warn dump( $model_obj );  
166                  my $additional;                  my $additional;
167                  $self->model_from_entry( $model_obj, $entry, %$additional );                  $self->model_from_entry( $model_obj, $entry, %$additional );
168                  $collection->add_record( $model_obj );                  $collection->add_record( $model_obj );
# Line 183  Result of last C<< $ldap->search >> requ Line 183  Result of last C<< $ldap->search >> requ
183    
184    $ldap->model_from_entry( $model, $entry, $additional );    $ldap->model_from_entry( $model, $entry, $additional );
185    
186    This method will join repeatable attributes by magic marker,
187    see C<XXX> in code!
188    
189  =cut  =cut
190    
191  sub model_from_entry {  sub model_from_entry {
# Line 194  sub model_from_entry { Line 197  sub model_from_entry {
197    
198          foreach my $attr ( $entry->attributes ) {          foreach my $attr ( $entry->attributes ) {
199                  if ( grep(/^\Q$attr\E$/, @columns ) ) {                  if ( grep(/^\Q$attr\E$/, @columns ) ) {
200                          $data->{$attr} = $entry->get_value( $attr );  #                       $data->{$attr} = $entry->get_value( $attr );
201                            my @var = $entry->get_value( $attr );
202    #                       warn "--- $attr = ",dump( @var );
203                            # XXX this rolls repeatable values into single field
204                            my $var = join(' <*> ', @var);
205                            $data->{$attr} = $var;
206  #               } elsif ( $attr !~ m/^(objectClass)$/i ) {  #               } elsif ( $attr !~ m/^(objectClass)$/i ) {
207                  } else {                  } else {
208                          Jifty->log->warn(ref($model)," doesn't have $attr");                          Jifty->log->warn(ref($model)," doesn't have $attr");

Legend:
Removed from v.106  
changed lines
  Added in v.181

  ViewVC Help
Powered by ViewVC 1.1.26