/[A3C]/bin/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/ldap.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (show annotations)
Wed Apr 9 21:32:34 2008 UTC (15 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1194 byte(s)
removed debug

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 Jifty->log->info( 'syncing all organizations and users' );
37
38 my $orgs = $ldap->collection( 'Organization', limit => $limit );
39
40 my $o_nr = 1;
41
42 while ( my $o = $orgs->next ) {
43 Jifty->log->info( 'sync organization ', $o_nr++, '/', $orgs->count, ' ', $o->name );
44 my $action = Jifty->web->new_action(
45 class => 'SyncOrganization',
46 moniker => 'sync',
47 arguments => {
48 cn => $o->cn,
49 }
50 );
51 $action->run;
52 if ( $action->result->success ) {
53 Jifty->log->info( $action->result->message );
54 } else {
55 Jifty->log->error( "Can't sync ", $o->name );
56 }
57 }
58 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26