summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 92031d0)
raw | patch | inline | side by side (parent: 92031d0)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 27 Feb 2008 08:03:50 +0000 (08:03 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 27 Feb 2008 08:03:50 +0000 (08:03 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9145 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index aac8b3c994bbdd8c3162011c7b84b33a5cf5957d..ddaae29b6b03da9a0654a56652ba564477545eb4 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
our $verbose;
our $forground;
our $cfg_file;
+our $ldap_handle;
# specifies the verbosity of the daemon_log
$verbose = 0 ;
}
-sub get_ldap_handle {
+sub refresh_ldap_handle {
my $mesg;
# Get an ldap handle, if we don't have one
if( defined $ldap_admin_password ) {
$mesg = $ldap_handle->bind( $ldap_admin_dn, password => $ldap_admin_password );
} else {
- $mesg = $ldap_handle->bind( $ldap_admin_dn );#
+ $mesg = $ldap_handle->bind( $ldap_admin_dn );
}
- }
- else {
+ } else {
$mesg = $ldap_handle->bind();
}
if( 0 != $mesg->code ) {
undef( $ldap_handle ) if( 81 == $mesg->code );
- daemon_log( "ch $$: LDAP bind: error ("
- . $mesg->code . ') - ' . $mesg->error . "\n" );
+ daemon_log( "ch $$: LDAP bind: error (". $mesg->code . ') - ' . $mesg->error . "\n", 1);
return 0;
}
- #HIER IST EIN FEHLER.....
+
return 1;
}
#
# ###################################################################
-
-
- $fai_server_db->add_dbentry( {
- table => $fai_server_tn,
- primkey => [],
- server => "dummyserver",
- release => "kleinkind",
- tag => "imwachstum",
- } );
- return;
+ $fai_server_db->add_dbentry( {
+ table => $fai_server_tn,
+ primkey => [],
+ server => "dummyserver",
+ release => "kleinkind",
+ tag => "imwachstum",
+ } );
+ return;
}
index 9a4b6657a07ea15af431a7288dedd4f1d7fc493a..d81ef57d5a6db68d02f95300da152236053c6ec7 100644 (file)
}
}
if(defined($ldap_uri) && length($ldap_uri)>0) {
- $ldap = Net::LDAP->new($ldap_uri);
- if (!$ldap) {
+ &main::refresh_ldap_handle();
+ if (!$main::ldap_handle) {
&main::daemon_log("Could not connect to LDAP Server at $ldap_uri!\n$@", 1);
- } else {
- $ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
}
} else {
- $ldap=undef;
+ $main::ldap_handle= undef;
}
# When interface is not configured (or 'all'), start arpwatch on all possible interfaces
&start(@_,$device);
},
_stop => sub {
- $ldap->unbind if (defined($ldap));
- $ldap->disconnect if (defined($ldap));
$_[KERNEL]->post( sprintf("arp_watch_$device") => 'shutdown' )
},
got_packet => \&got_packet,
&start(@_,$device);
},
_stop => sub {
- $ldap->unbind if (defined($ldap));
- $ldap->disconnect if (defined($ldap));
$_[KERNEL]->post( sprintf("arp_watch_$device") => 'shutdown' )
},
got_packet => \&got_packet,
": ".$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}.
"/".$hosts_database->{$packet->{source_haddr}}->{macAddress},4);
&add_ldap_entry(
- $ldap,
+ $main::ldap_handle,
$ldap_base,
$hosts_database->{$packet->{source_haddr}}->{macAddress},
'new-system',
"->".$packet->{source_ipaddr}, 4);
$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}= $packet->{source_ipaddr};
&change_ldap_entry(
- $ldap,
+ $main::ldap_handle,
$ldap_base,
$hosts_database->{$packet->{source_haddr}}->{macAddress},
'ip-changed',
my $mac=shift;
my $result={};
- if(defined($ldap)) {
+ if(defined($main::ldap_handle)) {
my $ldap_result= &search_ldap_entry(
- $ldap,
+ $main::ldap_handle,
$ldap_base,
"(|(macAddress=$mac)(dhcpHWAddress=ethernet $mac))"
);
if (defined($ip)) {
$replace->{'ipHostNumber'} = $ip;
}
- my $result = $ldap->modify( $dn, replace => $replace );
+ my $result = $main::ldap_handle->modify( $dn, replace => $replace );
# for $result->code constants please look at Net::LDAP::Constant
if($result->code == 32) { # entry doesnt exists
index 50efa409ccf4dc5a3330c11cab97751c81e83056..19a4dfcac8e74cbea03a628f789abfddc6eb8aa5 100644 (file)
my $network_interface;
my $no_bus;
my (@ldap_cfg, @pam_cfg, @nss_cfg, $goto_admin, $goto_secret);
+my $mesg;
my %cfg_defaults = (
"bus" => {
# Unit tag can be defined in config
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
# Read gosaUnitTag from LDAP
- my $tmp_ldap= Net::LDAP->new($ldap_uri);
- if( defined($tmp_ldap) ) {
+ &main::refresh_ldap_handle();
+ if( defined($main::ldap_handle) ) {
&main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $server_mac_address",5);
- my $mesg= $tmp_ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
# Perform search for Unit Tag
- $mesg = $tmp_ldap->search(
+ $mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
my $hostname= `hostname -f`;
chomp($hostname);
&main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
- $mesg = $tmp_ldap->search(
+ $mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
$hostname= `hostname -s`;
chomp($hostname);
&main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
- $mesg = $tmp_ldap->search(
+ $mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
}
}
}
- $tmp_ldap->unbind;
} else {
&main::daemon_log("INFO: Using gosaUnitTag from config-file: $main::gosa_unit_tag",5);
}
}
# Build LDAP connection
- my $ldap = Net::LDAP->new($ldap_uri);
- if( not defined $ldap ) {
+ &main::refresh_ldap_handle();
+ if( not defined $main::ldap_handle ) {
&main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
-
- # Bind to a directory with dn and password
- my $mesg= $ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
-
# Perform search
- $mesg = $ldap->search( base => $ldap_base,
+ $mesg = $main::ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'gotoLdapServer', 'gosaUnitTag', 'FAIclass'],
filter => "(&(objectClass=GOhard)(macaddress=$macaddress))");
# Do we need to look at an object class?
if (length(@servers) < 1){
- $mesg = $ldap->search( base => $ldap_base,
+ $mesg = $main::ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'gotoLdapServer', 'FAIclass'],
filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
if (defined $unit_tag){
# Find admin base and department name
- $mesg = $ldap->search( base => $ldap_base,
+ $mesg = $main::ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'ou'],
filter => "(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$unit_tag))");
$data{'unit_tag'}= $unit_tag;
}
-
- # Unbind
- $mesg = $ldap->unbind;
- if($mesg->code) {
- &main::daemon_log($mesg->error, 1);
- return;
- }
-
# Send information
return &build_msg("new_ldap_config", $server_address, $address, \%data);
}
}
# Build LDAP connection
- my $ldap = Net::LDAP->new($ldap_uri);
- if( not defined $ldap ) {
+ &main::refresh_ldap_handle();
+ if( not defined $main::ldap_handle ) {
&main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
- # Bind to a directory with dn and password
- my $mesg= $ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
-
# Perform search
- $mesg = $ldap->search(
+ $mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
if(defined($entry->get_value("gotoHardwareChecksum"))) {
if(! $entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum) {
$entry->replace(gotoHardwareChecksum => $gotoHardwareChecksum);
- if($entry->update($ldap)) {
+ if($entry->update($main::ldap_handle)) {
&main::daemon_log("Hardware changed! Detection triggered.", 4);
}
} else {
$data{'goto_secret'}= $goto_secret;
}
- # Unbind
- $mesg = $ldap->unbind;
-
&main::daemon_log("Send detect_hardware message to $address", 4);
# Send information
index 297b91f1d6bb7d1d02e8d200dae7ef7a13e5de72..fe3a373f91952267bc2f55630465dbfb1dfb8e42 100644 (file)
my $ldap_base;
my $ldap_admin_dn;
my $ldap_admin_password;
+my $mesg;
my %cfg_defaults = (
"server" => {
return;
}
# Build LDAP connection
- my $ldap = Net::LDAP->new($ldap_uri);
- if( not defined $ldap ) {
+ &main::refresh_ldap_handle();
+ if( not defined $main::ldap_handle ) {
&main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
- # Bind to a directory with dn and password
- my $mesg= $ldap->bind($ldap_admin_dn, password => $ldap_admin_password);
-
# Perform search
- $mesg = $ldap->search(
+ $mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
$entry->add("objectClass" => "gosaAdministrativeUnitTag");
$entry->add("gosaUnitTag" => $main::gosa_unit_tag);
}
- my $res=$entry->update($ldap);
+ my $res=$entry->update($main::ldap_handle);
if(defined($res->{'errorMessage'}) &&
length($res->{'errorMessage'}) >0) {
&main::daemon_log("ERROR: can not add entries to LDAP: ".$res->{'errorMessage'}, 1);
return;
} else {
# Fill $mesg again
- $mesg = $ldap->search(
+ $mesg = $main::ldap_handle->search(
base => $ldap_base,
scope => 'sub',
filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
}
}
- my $res=$entry->update($ldap);
+ my $res=$entry->update($main::ldap_handle);
if(defined($res->{'errorMessage'}) &&
length($res->{'errorMessage'}) >0) {
&main::daemon_log("ERROR: can not add entries to LDAP: ".$res->{'errorMessage'}, 1);