39 |
|
|
40 |
require 'config.pl' if -e 'config.pl'; |
require 'config.pl' if -e 'config.pl'; |
41 |
|
|
|
my $dbh = DBI->connect($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr; |
|
|
|
|
42 |
# we need reverse LDAP -> SQL mapping for where clause |
# we need reverse LDAP -> SQL mapping for where clause |
43 |
|
|
44 |
my $ldap_sql_mapping = { |
my $ldap_sql_mapping = { |
206 |
; |
; |
207 |
|
|
208 |
warn "# SQL:\n$sql\n# DATA: ",dump( @values ); |
warn "# SQL:\n$sql\n# DATA: ",dump( @values ); |
209 |
|
my $dbh = DBI->connect_cached($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr; |
210 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $dbh->prepare( $sql ); |
211 |
$sth->execute( @values ); |
$sth->execute( @values ); |
212 |
|
|
219 |
|
|
220 |
my ( $dn, $attributes ) = _dn_attributes( $row, $base ); |
my ( $dn, $attributes ) = _dn_attributes( $row, $base ); |
221 |
|
|
222 |
warn "# dn $last_dn ... $dn\n"; |
warn "## dn $last_dn ... $dn\n" if $debug; |
223 |
|
|
224 |
if ( $dn ne $last_dn ) { |
if ( $dn ne $last_dn ) { |
225 |
|
|
226 |
if ( $entry ) { |
if ( $entry ) { |
227 |
#$entry->changetype( 'modify' ); |
#$entry->changetype( 'modify' ); |
228 |
warn "### entry ",$entry->dump( \*STDERR ); |
warn "### entry ",$entry->dump( \*STDERR ) if $debug; |
229 |
push @entries, $entry; |
push @entries, $entry; |
230 |
undef $entry; |
undef $entry; |
231 |
} |
} |
240 |
} else { |
} else { |
241 |
foreach my $n ( keys %$attributes ) { |
foreach my $n ( keys %$attributes ) { |
242 |
my $v = $attributes->{$n}; |
my $v = $attributes->{$n}; |
243 |
warn "# attr $n = $v\n"; |
warn "## attr $n = $v\n" if $debug; |
244 |
$entry->add( $n, $v ) if $entry->get_value( $n ) ne $v; |
$entry->add( $n, $v ) if $entry->get_value( $n ) ne $v; |
245 |
} |
} |
246 |
} |
} |
251 |
} |
} |
252 |
|
|
253 |
if ( $entry ) { |
if ( $entry ) { |
254 |
warn "### last entry ",$entry->dump( \*STDERR ); |
warn "### last entry ",$entry->dump( \*STDERR ) if $debug; |
255 |
push @entries, $entry; |
push @entries, $entry; |
256 |
} |
} |
257 |
|
|