/[A3C]/bin/import-ldap.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/import-ldap.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 106 - (show annotations)
Thu May 1 17:06:02 2008 UTC (15 years, 11 months ago) by dpavlin
Original Path: bin/ldap.pl
File MIME type: text/plain
File size: 1400 byte(s)
massive re-structuring to enable models specified in configuration file

- version bump [0.04]
- SyncOrganization now accept org_uid as argument
- objectClass(es) for person and organization are now in config.yml
  as well as link between them (filter on person)
- config.yml is now checked for validity in A3C::LDAP
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use lib 'lib';
7
8 use Jifty;
9 use A3C::LDAP;
10 use Data::Dump qw/dump/;
11 use Getopt::Long;
12
13 BEGIN { Jifty->new; };
14 Jifty->web->request(Jifty::Request->new);
15 Jifty->web->response(Jifty::Response->new);
16
17 my $limit = 0;
18 my @models;
19 GetOptions(
20 'limit=i', => \$limit,
21 'model=s', => \@models,
22 );
23
24 my $ldap = A3C::LDAP->new;
25
26 if ( @models ) {
27
28 Jifty->log->info( 'syncing: ', join(',', @models) );
29
30 foreach my $model ( @models ) {
31 my $collection = $ldap->collection( $model, limit => $limit );
32 Jifty->log->info( 'found ', $collection->count, ' entries for ', $model );
33 }
34 } else {
35
36 my $person_oc = $ldap->objectClass->{person};
37 my $org_oc = $ldap->objectClass->{organization};
38
39 Jifty->log->info( "syncing all $org_oc organizations and $person_oc persons" );
40
41 my $orgs = $ldap->collection( $org_oc , limit => $limit );
42
43 my $o_nr = 1;
44
45 while ( my $o = $orgs->next ) {
46 Jifty->log->info( 'sync organization ', $o_nr++, '/', $orgs->count, ' ', $o->name );
47 my $org_uid = $o->__value( $ldap->link->{value_from} ) || die "can't find org_uid";
48 my $action = Jifty->web->new_action(
49 class => 'SyncOrganization',
50 moniker => 'sync',
51 arguments => {
52 org_uid => $org_uid,
53 }
54 );
55 $action->run;
56 if ( $action->result->success ) {
57 Jifty->log->info( $action->result->message );
58 } else {
59 Jifty->log->error( "Can't sync ", $o->name );
60 }
61 }
62 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26