Index: /LATMOS-Accounts/bin/la-sync
===================================================================
--- /LATMOS-Accounts/bin/la-sync	(revision 41)
+++ /LATMOS-Accounts/bin/la-sync	(revision 41)
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use LATMOS::Accounts;
+use LATMOS::Accounts::Synchro;
+use Getopt::Long;
+use Pod::Usage;
+
+=head1 NAME
+
+    la-sync - Tools to synchronize base
+
+=head1 SYNOPSIS
+
+Show configured bases:
+
+    la-sync [options]
+
+=cut
+
+GetOptions(
+    'c|config=s' => \my $config,
+    'help'       => sub { pod2usage(0) },
+    'from=s'     => \my $from,
+    'to=s'       => \my @to,
+) or pod2usage();
+
+=head1 OPTIONS
+
+=item -c|--config configfile
+
+Use this configuration file instead default
+
+=item --from basename
+
+Specify souce base to use
+
+=item --to basename
+
+Specify destination base to use, this option can be used
+severals times
+
+=cut
+
+my $LA = LATMOS::Accounts->new($config);
+
+# TODO LATMOS::Accounts::Synchro creation can be done by LATMOS::Account
+my $labfrom = $from ? $LA->base($from) : $LA->default_base;
+
+my @labto = map { $LA->base($_) }
+    @to
+        ? @to
+        : ($LA->config_sync_base($from
+                ? $from
+                : $LA->default_base_name
+        )
+);
+
+my $sync = LATMOS::Accounts::Synchro->new($labfrom, [ @labto ]);
+$sync->load_dest and return;
+$sync->process or warn "Sync has failed\n";
Index: /LATMOS-Accounts/lib/LATMOS/Accounts.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts.pm	(revision 40)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts.pm	(revision 41)
@@ -75,4 +75,9 @@
 }
 
+sub config_sync_base {
+    my ($self, $from) = @_;
+    return split(/ /, $self->val($from, 'push', ''));
+} 
+
 1;
 
@@ -116,5 +121,5 @@
 =head1 AUTHOR
 
-Thauvin Olivier, E<lt>olivier.thauvin.ipsl.fr@localdomainE<gt>
+Thauvin Olivier, E<lt>olivier.thauvin@latmosipsl.frE<gt>
 
 =head1 COPYRIGHT AND LICENSE
Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm	(revision 40)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm	(revision 41)
@@ -39,5 +39,11 @@
     eval "require LATMOS::Accounts::Bases::$pclass;";
     if ($@) { return } # error message ?
-    return "LATMOS::Accounts::Bases::$pclass"->new(%options);
+    my $base = "LATMOS::Accounts::Bases::$pclass"->new(%options);
+    $base->{_type} = lc($pclass);
+    $base
+}
+
+sub type {
+    $_[0]->{_type};
 }
 
@@ -76,4 +82,29 @@
     my $pclass = $self->_load_obj_class($otype) or return;
     $pclass->_get_field_name($c_fields);
+}
+
+=head2 list_supported_objects(@otype)
+
+Return a list of supported object
+
+@type is an additionnal list of objects to check
+
+=cut
+
+sub list_supported_objects {
+    my ($self, @otype) = @_;
+    return grep { $self->is_supported_object($_) }
+        (qw(user group), @otype);
+}
+
+=head2 is_supported_object($otype)
+
+Return true is object type $otype is supported
+
+=cut
+
+sub is_supported_object {
+    my ($self, $otype) = @_;
+    return $self->_load_obj_class($otype) ? 1 : 0;
 }
 
Index: /LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
===================================================================
--- /LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm	(revision 41)
+++ /LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm	(revision 41)
@@ -0,0 +1,150 @@
+package LATMOS::Accounts::Synchro;
+
+use 5.010000;
+use strict;
+use warnings;
+use base qw(Config::IniFiles);
+use LATMOS::Accounts::Bases;
+
+=head1 NAME
+
+LATMOS::Accounts::Synchro - Perl extension for blah blah blah
+
+=head1 SYNOPSIS
+
+  use LATMOS::Accounts;
+  blah blah blah
+
+=head1 DESCRIPTION
+
+Stub documentation for LATMOS::Accounts, created by h2xs. It looks like the
+author of the extension was negligent enough to leave the stub
+unedited.
+
+Blah blah blah.
+
+=head1 FUNCTIONS
+
+=cut
+
+our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0];
+
+=head2 new($from, $to)
+
+Create a new synchronisation where $from and $to are LATMOS::Accounts::Base
+based objects. $to can be an array ref of objects.
+
+=cut
+
+sub new {
+    my ($class, $from, $to) = @_;
+
+    my $self = {};
+
+    $self->{from} = $from;
+
+    # allow ref and array ref of, eg
+    # to = $foo and $to = [ $foo, $bar ]
+    foreach (ref $to ? @{ $to || []} : ($to)) {
+        push(@{$self->{to}}, $_);
+    }
+    bless($self, $class)
+}
+
+sub from {
+    my ($self) = @_;
+    return $self->{from}
+}
+
+sub to {
+    my ($self) = @_;
+    return @{$self->{to} || []};
+}
+
+=head2 load_dest
+
+Try to loaded all base, return the count of filtrered base which cannot
+be loaded
+
+=cut
+
+sub load_dest {
+    my ($self) = @_;
+    my @loaded;
+    my $unloaded = 0;
+    foreach ($self->to) {
+        if($_->load) {
+            push(@loaded, $_);
+        } else {
+            $unloaded++;
+        }
+    }
+    $self->{to} = \@loaded;
+    return $unloaded;
+}
+
+sub process {
+    my ($self, %options) = @_;
+
+    $self->from->load or return;
+    # if any cannot be loaded, return,
+    # TODO we need a way to force if some still can be sync
+    $self->load_dest and return;
+    
+    # listing existing obj one time:
+    foreach my $otype ($self->from->list_supported_objects) {
+        
+        # If no dest support $otype, we skip
+        my @obj_dest_base = grep {
+            $_->is_supported_object($otype)
+        } $self->to or next;
+
+        # loading object list one time for all
+        # TODO optimize this, using rev of objects
+        my @lobjfrom = $self->from->list_objects($otype);
+
+        warn "Sync objects $otype\n";
+        foreach my $destbase (@obj_dest_base) {
+            warn "objects $otype => " . $destbase->type . "\n";
+            my %exists = map { $_ => 1 } $destbase->list_objects($otype);
+            foreach (@lobjfrom) {
+                if (!$exists{$_}) {
+                    warn "  $otype $_: created\n";
+                }
+            }
+        }
+    }
+
+    1;
+}
+
+1;
+
+__END__
+# Below is stub documentation for your module. You'd better edit it!
+
+=head1 SEE ALSO
+
+Mention other useful documentation such as the documentation of
+related modules or operating system documentation (such as man pages
+in UNIX), or any relevant external documentation such as RFCs or
+standards.
+
+If you have a mailing list set up for your module, mention it here.
+
+If you have a web site set up for your module, mention it here.
+
+=head1 AUTHOR
+
+Thauvin Olivier, E<lt>olivier.thauvin@latmosipsl.frE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2009 by Thauvin Olivier
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.10.0 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
