Mailinglist Archive: yast-commit (459 mails)

< Previous Next >
[yast-commit] r60777 - in /trunk/ldap-server: ./ src/ src/agent/ src/lib/
  • From: rhafer@xxxxxxxxxxxxxxxx
  • Date: Tue, 09 Feb 2010 16:23:33 -0000
  • Message-id: <E1Ness9-0008Gh-NU@xxxxxxxxxxxxxxxx>
Author: rhafer
Date: Tue Feb 9 17:23:31 2010
New Revision: 60777

URL: http://svn.opensuse.org/viewcvs/yast?rev=60777&view=rev
Log:
syncrepl merge from sle-sp1 branch, consumer support (revisions 58969-59181)

Modified:
trunk/ldap-server/ (props changed)
trunk/ldap-server/src/LdapDatabase.ycp
trunk/ldap-server/src/LdapServer.pm
trunk/ldap-server/src/agent/SlapdConfigAgent.cc
trunk/ldap-server/src/agent/SlapdConfigAgent.h
trunk/ldap-server/src/dialogs.ycp
trunk/ldap-server/src/lib/slapd-config.cpp
trunk/ldap-server/src/lib/slapd-config.h
trunk/ldap-server/src/tree_structure.ycp

Modified: trunk/ldap-server/src/LdapDatabase.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/LdapDatabase.ycp?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/LdapDatabase.ycp (original)
+++ trunk/ldap-server/src/LdapDatabase.ycp Tue Feb 9 17:23:31 2010
@@ -1406,6 +1406,377 @@
return true;
}

+ global term GetSyncConsWidget()
+ {
+ term widget =
+ `Top(
+ `VBox(
+ `Left(
+ `CheckBox( `id( `cb_syncrepl ), `opt(`notify), _("This
database is a Replication Consumer"), false )
+ ),
+ `Frame( `id( `f_synccons ), _("Consumer Settings" ),
+ `VBox(
+ `Left(
+ `VSquash(
+ `HBox(
+ `ComboBox( `id( `cb_sync_prot ),
`opt(`notify), _("Protocol"), [ "ldap", "ldaps" ] ),
+ `HSpacing(),
+ `InputField( `id( `te_sync_target ),
`opt(`hstretch), _("Provider Name"), "" ),
+ `HSpacing(),
+ `HSquash(
+ `IntField( `id(`if_sync_port),
"Port", 0, 65536, 389)
+ ),
+ `HSpacing(),
+ `VBox(
+ `Bottom(
+ `CheckBox( `id( `cb_start_tls
), _("Use StartTLS"), true )
+ ),
+ `VSpacing(0.3)
+ )
+ )
+ )
+ ),
+ `VSpacing(0.3),
+ `Left(
+ `InputField( `id( `te_sync_base ),
`opt(`hstretch), _("Base DN"), "" )
+ ),
+ `VSpacing(0.3),
+ `Left(
+ `HBox(
+ `ComboBox( `id( `cb_sync_type ),
`opt(`notify),
+ _("Replication Type"), [
"refreshAndPersist", "refreshOnly" ] ),
+ `HSpacing(),
+ `VSquash(
+ `HBox( `id( `hb_rep_interval ),
+ `VBox(
+ `Bottom(
+ `Label( _("Replication
Interval") )
+ )
+ ),
+ `HSpacing(),
+ `HSquash(
+ `IntField(
`id(`if_sync_int_d), _("Days"), 0, 99, 0)
+ ),
+ `HSpacing(),
+ `HSquash(
+ `IntField(
`id(`if_sync_int_h), _("Hours"), 0, 23, 0)
+ ),
+ `HSpacing(),
+ `HSquash(
+ `IntField(
`id(`if_sync_int_m), _("Minutes"), 0, 59, 0)
+ ),
+ `HSpacing(),
+ `HSquash(
+ `IntField(
`id(`if_sync_int_s), _("Seconds"), 0, 59, 0)
+ ),
+ `HStretch()
+ )
+ )
+ )
+ ),
+ `VSpacing(0.3),
+ `Left(
+ `HBox(
+ `InputField( `id( `te_sync_binddn ),
`opt(`hstretch), _("Authentication DN"), "" ),
+ `HSpacing(),
+ `Password( `id( `te_sync_cred ),
`opt(`hstretch), _("Password"), "" )
+ )
+ ),
+ `VSpacing(0.3),
+ `Left(
+ `VSquash(
+ `HBox(
+ `VBox(
+ `Bottom(
+ `CheckBox( `id( `cb_update_ref
), `opt(`notify), _("Custom update referral") )
+ ),
+ `VSpacing(0.3)
+ ),
+ `HSpacing(),
+ `ComboBox( `id( `cb_updateref_prot ),
`opt(`notify), _("Protocol"), [ "ldap", "ldaps" ] ),
+ `HSpacing(),
+ `InputField( `id( `te_updateref_target
), `opt(`hstretch), _("Target Host"), "" ),
+ `HSpacing(),
+ `HSquash(
+ `IntField(
`id(`if_updateref_port), "Port", 0, 65536, 389)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ );
+ return widget;
+ }
+
+ global boolean DbSyncConsRead( symbol handler_cmd, integer index, map
synccons )
+ {
+ y2milestone("DbSyncConsRead %1 %2", handler_cmd, index);
+ if ( size(synccons) == 0 )
+ {
+ UI::ChangeWidget( `f_synccons, `Enabled, false );
+ }
+ else
+ {
+ UI::ChangeWidget( `f_synccons, `Enabled, true );
+ UI::ChangeWidget( `cb_syncrepl, `Value, true );
+ map<string,any> provider = synccons["provider"]:$[];
+ UI::ChangeWidget( `te_sync_target, `Value,
(string)provider["target"]:"");
+ UI::ChangeWidget( `cb_sync_prot, `Value,
(string)provider["protocol"]:"");
+ if ( (string)provider["protocol"]:"" == "ldaps")
+ {
+ UI::ChangeWidget( `cb_start_tls, `Value, false );
+ UI::ChangeWidget( `cb_start_tls, `Enabled, false );
+ }
+ else
+ {
+ UI::ChangeWidget( `cb_start_tls, `Value,
(boolean)synccons["starttls"]:true );
+ }
+ UI::ChangeWidget( `if_sync_port, `Value,
(integer)provider["port"]:0);
+ UI::ChangeWidget( `te_sync_base, `Value,
(string)synccons["searchbase"]:"");
+ UI::ChangeWidget( `cb_sync_type, `Value,
(string)synccons["type"]:"");
+ if ( (string)synccons["type"]:"" == "refreshAndPersist" )
+ {
+ UI::ChangeWidget( `hb_rep_interval, `Enabled, false );
+ }
+ else
+ {
+ UI::ChangeWidget( `if_sync_int_d, `Value,
(integer)synccons["interval","days"]:0 );
+ UI::ChangeWidget( `if_sync_int_h, `Value,
(integer)synccons["interval","hours"]:0 );
+ UI::ChangeWidget( `if_sync_int_m, `Value,
(integer)synccons["interval","mins"]:0 );
+ UI::ChangeWidget( `if_sync_int_s, `Value,
(integer)synccons["interval","secs"]:0 );
+ }
+ UI::ChangeWidget( `te_sync_binddn, `Value,
(string)synccons["binddn"]:"");
+ UI::ChangeWidget( `te_sync_cred, `Value,
(string)synccons["credentials"]:"");
+ map <string,any> updateref = synccons["updateref"]:$[];
+ if (size(updateref) == 0 )
+ {
+ // no updateref
+ UI::ChangeWidget( `cb_update_ref, `Value, true );
+ UI::ChangeWidget( `te_updateref_target, `Value, "" );
+ }
+ else if ( (boolean)updateref["use_provider"]:true )
+ {
+ UI::ChangeWidget( `cb_update_ref, `Value, false );
+ UI::ChangeWidget( `cb_updateref_prot, `Enabled, false );
+ UI::ChangeWidget( `te_updateref_target, `Enabled, false );
+ UI::ChangeWidget( `if_updateref_port, `Enabled, false );
+ }
+ else
+ {
+ UI::ChangeWidget( `cb_update_ref, `Value, true );
+ UI::ChangeWidget( `cb_updateref_prot, `Value,
(string)updateref["protocol "]:"ldap" );
+ UI::ChangeWidget( `te_updateref_target, `Value,
(string)updateref["target"]:"" );
+ UI::ChangeWidget( `if_updateref_port, `Value,
(integer)updateref["port"]:389 );
+ }
+ }
+ return true;
+ }
+
+ global boolean DbSyncConsInput( symbol handler_cmd, integer index )
+ {
+ y2milestone("DbSyncConsInput %1 %2", handler_cmd, index);
+ if ( handler_cmd == `cb_syncrepl )
+ {
+ if ( UI::QueryWidget( `cb_syncrepl, `Value ) == true )
+ {
+ UI::ChangeWidget( `f_synccons, `Enabled, true );
+ if ( UI::QueryWidget( `te_sync_base, `Value ) == "" )
+ {
+ map<string,any> db = LdapServer::ReadDatabase(index);
+ string basedn = db["suffix"]:"";
+ UI::ChangeWidget( `te_sync_base, `Value, basedn );
+ }
+ }
+ else
+ {
+ UI::ChangeWidget( `f_synccons, `Enabled, false );
+ }
+ }
+ if ( handler_cmd == `cb_sync_prot )
+ {
+ string prot = (string) UI::QueryWidget( `cb_sync_prot, `Value
);
+ integer port = (integer) UI::QueryWidget( `if_sync_port,
`Value );
+ if ( prot == "ldaps" )
+ {
+ UI::ChangeWidget( `cb_start_tls, `Value, false );
+ UI::ChangeWidget( `cb_start_tls, `Enabled, false );
+ if ( port == 389 )
+ {
+ UI::ChangeWidget( `if_sync_port, `Value, 636 );
+ }
+ }
+ else
+ {
+ UI::ChangeWidget( `cb_start_tls, `Value, true );
+ UI::ChangeWidget( `cb_start_tls, `Enabled, true );
+ if ( port == 636 )
+ {
+ UI::ChangeWidget( `if_sync_port, `Value, 389 );
+ }
+ }
+ }
+ if ( handler_cmd == `cb_update_ref )
+ {
+ if ( (boolean)UI::QueryWidget( `cb_update_ref, `Value ) == true )
+ {
+ UI::ChangeWidget( `te_updateref_target, `Enabled, true );
+ UI::ChangeWidget( `cb_updateref_prot, `Enabled, true );
+ UI::ChangeWidget( `if_updateref_port, `Enabled, true );
+ UI::ChangeWidget( `te_updateref_target, `Value, "" );
+ }
+ else
+ {
+ UI::ChangeWidget( `te_updateref_target, `Enabled, false );
+ UI::ChangeWidget( `cb_updateref_prot, `Enabled, false );
+ UI::ChangeWidget( `if_updateref_port, `Enabled, false );
+ UI::ChangeWidget( `te_updateref_target, `Value, "" );
+ }
+ }
+ if ( handler_cmd == `cb_updateref_prot )
+ {
+ string prot = (string) UI::QueryWidget( `cb_updateref_prot,
`Value );
+ integer port = (integer) UI::QueryWidget( `if_updateref_port,
`Value );
+ if ( prot == "ldaps" )
+ {
+ if ( port == 389 )
+ {
+ UI::ChangeWidget( `if_updateref_port, `Value, 636 );
+ }
+ }
+ else
+ {
+ if ( port == 636 )
+ {
+ UI::ChangeWidget( `if_updateref_port, `Value, 389 );
+ }
+ }
+ }
+ if ( (string)UI::QueryWidget( `cb_sync_type, `Value ) ==
"refreshAndPersist" )
+ {
+ UI::ChangeWidget( `hb_rep_interval, `Enabled, false );
+ }
+ else
+ {
+ UI::ChangeWidget( `hb_rep_interval, `Enabled, true );
+ }
+
+ return true;
+ }
+
+ global boolean DbSyncConsCheck( integer index )
+ {
+ y2milestone("DbSyncConsCheck %1", index);
+ if ( UI::QueryWidget( `cb_syncrepl, `Value ) == true )
+ {
+ if ( (string)UI::QueryWidget( `cb_sync_type, `Value ) ==
"refreshOnly" )
+ {
+ integer days = (integer)UI::QueryWidget( `if_sync_int_d,
`Value );
+ integer hours = (integer)UI::QueryWidget( `if_sync_int_h,
`Value );
+ integer mins = (integer)UI::QueryWidget( `if_sync_int_m,
`Value );
+ integer secs = (integer)UI::QueryWidget( `if_sync_int_s,
`Value );
+ if(days == 0 && hours == 0 && mins == 0 && secs == 0 )
+ {
+ Popup::Error( _("Invalid Replication Interval specified")
);
+ return false;
+ }
+ }
+ string prot = (string)UI::QueryWidget( `cb_sync_prot, `Value );
+ string target = (string)UI::QueryWidget( `te_sync_target, `Value );
+ integer port = (integer)UI::QueryWidget( `if_sync_port, `Value );
+
+ // test connection
+ map<string,any> provider = $[
+ "protocol" : prot,
+ "target" : target,
+ "port" : port
+ ];
+ map<string,any> testparm = $[];
+ testparm = add(testparm, "target", provider );
+ testparm = add(testparm, "starttls",
(boolean)UI::QueryWidget(`cb_start_tls, `Value) );
+ testparm = add(testparm, "binddn",
(string)UI::QueryWidget(`te_sync_binddn, `Value) );
+ testparm = add(testparm, "credentials",
(string)UI::QueryWidget(`te_sync_cred, `Value) );
+ testparm = add(testparm, "basedn",
(string)UI::QueryWidget(`te_sync_base, `Value) );
+ if(!(boolean)SCR::Execute( .ldapserver.remoteBindCheck, testparm )
)
+ {
+ map<string,any> err = SCR::Error(.ldapserver);
+ return Popup::ContinueCancelHeadline( _("Checking LDAP
connectivity to the provider failed"),
+ _("The test returned the
following error messages:")
+ + "\n\n\"" +
+ (string)err["summary"]:"" +
"\"\n\"" + (string)err["description"]:""
+ + "\"\n\n" +
+ _("Do you want to still want to
continue?"));
+ }
+ if(!(boolean)SCR::Execute( .ldapserver.remoteLdapSyncCheck,
testparm ) )
+ {
+ map<string,any> err = SCR::Error(.ldapserver);
+ return Popup::ContinueCancelHeadline( _("Checking the LDAPsync
capabilities of the provider failed"),
+ _("Please verify that the
target server is enabled to be a LDAPsync provider")
+ + "\n\n" +
+ _("The test returned the
following error messages:")
+ + "\n\"" +
+ (string)err["summary"]:""+
"\"\n\"" + (string)err["description"]:""
+ + "\"\n\n" +
+ _("Do you want to still want to
continue?"));
+ }
+ }
+ return true;
+ }
+
+ global map<string,any> DbSyncConsWrite( integer index )
+ {
+ y2milestone("DbSyncConsWrite %1", index);
+ map<string,any> result = $[];
+ if ( UI::QueryWidget( `cb_syncrepl, `Value ) == true )
+ {
+ string prot = (string)UI::QueryWidget( `cb_sync_prot, `Value );
+ string target = (string)UI::QueryWidget( `te_sync_target, `Value );
+ integer port = (integer)UI::QueryWidget( `if_sync_port, `Value );
+ map<string,any> provider = $[
+ "protocol" : prot,
+ "target" : target,
+ "port" : port
+ ];
+ result = add(result, "provider", provider );
+ result = add(result, "starttls",
(boolean)UI::QueryWidget(`cb_start_tls, `Value) );
+
+ string type = (string)UI::QueryWidget( `cb_sync_type, `Value );
+ result = add(result, "type", type );
+
+ if ( type == "refreshOnly" )
+ {
+ map<string,integer> iv = $[
+ "days" : (integer)UI::QueryWidget( `if_sync_int_d,
`Value ),
+ "hours" : (integer)UI::QueryWidget( `if_sync_int_h,
`Value ),
+ "mins" : (integer)UI::QueryWidget( `if_sync_int_m,
`Value ),
+ "secs" : (integer)UI::QueryWidget( `if_sync_int_s,
`Value ),
+ ];
+ result = add( result, "interval", iv );
+ }
+
+ string basedn = (string)UI::QueryWidget( `te_sync_base, `Value );
+ string binddn = (string)UI::QueryWidget( `te_sync_binddn, `Value );
+ string cred = (string)UI::QueryWidget( `te_sync_cred, `Value );
+ result = add(result, "basedn", basedn );
+ result = add(result, "binddn", binddn );
+ result = add(result, "credentials", cred );
+ if ( (boolean) UI::QueryWidget( `cb_update_ref, `Value) )
+ {
+ map<string,any> updateref = $[];
+ if ( (string)UI::QueryWidget(`cb_updateref_prot, `Value) != ""
)
+ {
+ updateref = add(updateref, "protocol",
(string)UI::QueryWidget(`cb_updateref_prot, `Value) );
+ updateref = add(updateref, "target",
(string)UI::QueryWidget(`te_updateref_target, `Value) );
+ updateref = add(updateref, "port",
(integer)UI::QueryWidget(`if_updateref_port, `Value) );
+ }
+ result = add(result, "updateref", updateref );
+ }
+ }
+ y2milestone("DbSyncConsWrite result: %1", result);
+ return result;
+ }
+
global term GetSyncProvWidget()
{
term widget =
@@ -1415,7 +1786,7 @@
`VBox(
`HBox(
`CheckBox( `id( `cb_synprov_enable ),`opt(`notify
),
- _("Enable ldapsync provider for this
database"), false
+ _("Enable ldapsync provider for this
database"), false
),
`HSpacing( `opt(`hstretch))
),

Modified: trunk/ldap-server/src/LdapServer.pm
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/LdapServer.pm?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/LdapServer.pm (original)
+++ trunk/ldap-server/src/LdapServer.pm Tue Feb 9 17:23:31 2010
@@ -1868,6 +1868,89 @@
return YaST::YCP::Boolean(1);
}

+BEGIN { $TYPEINFO {ReadSyncRepl} = ["function", [ "map" , "string", "any" ],
"integer" ]; }
+sub ReadSyncRepl
+{
+ my ($self, $index) = @_;
+ y2milestone("ReadSyncRepl ", $index);
+ my $syncrepl = SCR->Read(".ldapserver.database.{".$index."}.syncrepl" );
+ y2milestone( "SyncRepl: ".Data::Dumper->Dump([$syncrepl]) );
+ if ( ! $syncrepl )
+ {
+ my $err = SCR->Error(".ldapserver");
+ $self->SetError( $err->{'summary'}, $err->{'description'} );
+ return undef;
+ }
+ if (defined $syncrepl->{'provider'} && defined
$syncrepl->{'provider'}->{'port'} )
+ {
+ $syncrepl->{'provider'}->{'port'} = YaST::YCP::Integer(
$syncrepl->{'provider'}->{'port'} );
+ }
+ if (defined $syncrepl->{'updateref'} )
+ {
+ if ( defined $syncrepl->{'updateref'}->{'port'} )
+ {
+ $syncrepl->{'updateref'}->{'port'} = YaST::YCP::Integer(
$syncrepl->{'updateref'}->{'port'} );
+ }
+ if ( defined $syncrepl->{'updateref'}->{'use_provider'} )
+ {
+ $syncrepl->{'updateref'}->{'use_provider'} = YaST::YCP::Boolean(
$syncrepl->{'updateref'}->{'use_provider'} );
+ }
+ }
+ if ( defined $syncrepl->{'interval'} )
+ {
+ $syncrepl->{'interval'}->{'days'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'days'} );
+ $syncrepl->{'interval'}->{'hours'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'hours'} );
+ $syncrepl->{'interval'}->{'mins'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'mins'} );
+ $syncrepl->{'interval'}->{'secs'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'secs'} );
+ }
+ if ( defined $syncrepl->{'starttls'} )
+ {
+ $syncrepl->{'starttls'} = YaST::YCP::Boolean( $syncrepl->{'starttls'}
);
+ }
+ return $syncrepl;
+}
+
+BEGIN { $TYPEINFO {WriteSyncRepl} = ["function", "boolean" , "integer",
["map", "string", "any" ] ]; }
+sub WriteSyncRepl
+{
+ my ( $self, $dbindex, $syncrepl) = @_;
+ y2milestone("WriteSyncRepl");
+ if (defined $syncrepl->{'provider'} && defined
$syncrepl->{'provider'}->{'port'} )
+ {
+ $syncrepl->{'provider'}->{'port'} = YaST::YCP::Integer(
$syncrepl->{'provider'}->{'port'} );
+ }
+ if (defined $syncrepl->{'updateref'} )
+ {
+ if ( defined $syncrepl->{'updateref'}->{'port'} )
+ {
+ $syncrepl->{'updateref'}->{'port'} = YaST::YCP::Integer(
$syncrepl->{'updateref'}->{'port'} );
+ }
+ if ( defined $syncrepl->{'updateref'}->{'use_provider'} )
+ {
+ $syncrepl->{'updateref'}->{'use_provider'} = YaST::YCP::Boolean(
$syncrepl->{'updateref'}->{'use_provider'} );
+ }
+ }
+ if ( defined $syncrepl->{'interval'} )
+ {
+ $syncrepl->{'interval'}->{'days'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'days'} );
+ $syncrepl->{'interval'}->{'hours'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'hours'} );
+ $syncrepl->{'interval'}->{'mins'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'mins'} );
+ $syncrepl->{'interval'}->{'secs'} = YaST::YCP::Integer(
$syncrepl->{'interval'}->{'secs'} );
+ }
+ if ( defined $syncrepl->{'starttls'} )
+ {
+ $syncrepl->{'starttls'} = YaST::YCP::Boolean( $syncrepl->{'starttls'}
);
+ }
+ y2milestone("SyncRepl: ".Data::Dumper->Dump([$syncrepl]) );
+ if ( ! SCR->Write(".ldapserver.database.{".$dbindex."}.syncrepl",
$syncrepl ) )
+ {
+ my $err = SCR->Error(".ldapserver");
+ $self->SetError( $err->{'summary'}, $err->{'description'} );
+ return YaST::YCP::Boolean(0);
+ }
+ return YaST::YCP::Boolean(1);
+}
+
BEGIN { $TYPEINFO {ReadSchemaList} = ["function", [ "list" , "string"] ]; }
sub ReadSchemaList
{

Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfigAgent.cc?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/agent/SlapdConfigAgent.cc (original)
+++ trunk/ldap-server/src/agent/SlapdConfigAgent.cc Tue Feb 9 17:23:31 2010
@@ -4,6 +4,7 @@
#include <LdifReader.h>
#include <LdifWriter.h>
#include <LDAPEntry.h>
+#include <LDAPUrl.h>
#include <SaslInteraction.h>
#include <algorithm>
#include <exception>
@@ -41,7 +42,6 @@
}
}

-
bool caseIgnoreCompare( char c1, char c2)
{
return toupper(c1) == toupper(c2);
@@ -391,6 +391,14 @@
return YCPBoolean(false);
}
}
+ else if ( path->component_str(0) == "remoteBindCheck" )
+ {
+ return YCPBoolean(remoteBindCheck(arg));
+ }
+ else if ( path->component_str(0) == "remoteLdapSyncCheck" )
+ {
+ return YCPBoolean(remoteSyncCheck(arg));
+ }
return YCPBoolean(true);
}

@@ -679,6 +687,9 @@
{
resMap.add( YCPString("sessionlog"),
YCPInteger(slog) );
}
+ // This is just that the map is not empty (e.g.
when syncprov is
+ // configured with default values)
+ resMap.add( YCPString("enabled"), YCPBoolean(true)
);
break;
}
}
@@ -750,6 +761,75 @@
return YCPNull();
}
}
+ else if ( dbComponent == "syncrepl" )
+ {
+ YCPMap resMap;
+ OlcSyncReplList srl = (*i)->getSyncRepl();
+ if ( ! srl.empty() )
+ {
+ boost::shared_ptr<OlcSyncRepl> sr = *srl.begin();
+ resMap.add( YCPString(OlcSyncRepl::RID), YCPInteger(
sr->getRid() ));
+ std::string proto,host;
+ int port;
+ sr->getProviderComponents(proto, host, port);
+ YCPMap providerMap;
+ providerMap.add( YCPString("protocol"),
YCPString(proto) );
+ providerMap.add( YCPString("target"), YCPString(host)
);
+ providerMap.add( YCPString("port"), YCPInteger(port) );
+ resMap.add( YCPString(OlcSyncRepl::PROVIDER),
providerMap );
+ resMap.add( YCPString(OlcSyncRepl::TYPE), YCPString(
sr->getType() ));
+ if ( sr->getStartTls() != OlcSyncRepl::StartTlsNo )
+ {
+ resMap.add( YCPString(OlcSyncRepl::STARTTLS),
YCPBoolean( true ));
+ }
+
+ if ( sr->getType() == "refreshOnly" )
+ {
+ YCPMap intervalMap;
+ int d,h,m,s;
+ sr->getInterval(d, h, m, s);
+ intervalMap.add( YCPString("days"), YCPInteger(d)
);
+ intervalMap.add( YCPString("hours"), YCPInteger(h)
);
+ intervalMap.add( YCPString("mins"), YCPInteger(m)
);
+ intervalMap.add( YCPString("secs"), YCPInteger(s)
);
+ resMap.add( YCPString( OlcSyncRepl::INTERVAL ),
intervalMap );
+ }
+
+ resMap.add( YCPString(OlcSyncRepl::BINDDN), YCPString(
sr->getBindDn() ));
+ resMap.add( YCPString(OlcSyncRepl::CREDENTIALS),
YCPString( sr->getCredentials()));
+ resMap.add( YCPString(OlcSyncRepl::BASE), YCPString(
sr->getSearchBase()));
+ std::string
updateref((*i)->getStringValue("olcUpdateRef"));
+ if (! updateref.empty() )
+ {
+ LDAPUrl updateUrl(updateref);
+ YCPMap updaterefMap;
+ std::string updateHost(updateUrl.getHost() );
+ std::string updateProt(updateUrl.getScheme() );
+ int updatePort(updateUrl.getPort() );
+
+ // don't set updateref when using updateref ==
provideruri
+ if ( updatePort != updatePort ||
+ updateHost != host ||
+ updateProt != proto )
+ {
+ updaterefMap.add( YCPString("protocol"),
YCPString( updateUrl.getScheme() ) );
+ updaterefMap.add( YCPString("target"),
YCPString( updateUrl.getHost() ) );
+ updaterefMap.add( YCPString("port"),
YCPInteger( updateUrl.getPort() ) );
+ updaterefMap.add( YCPString("use_provider"),
YCPBoolean( false ) );
+ }
+ else
+ {
+ updaterefMap.add( YCPString("use_provider"),
YCPBoolean( true ) );
+ }
+ resMap.add( YCPString("updateref"), updaterefMap );
+ }
+ else
+ {
+ resMap.add( YCPString("updateref"), YCPMap() );
+ }
+ }
+ return resMap;
+ }
else
{
lastError->add(YCPString("summary"), YCPString("Read
Failed") );
@@ -1445,6 +1525,107 @@
(*i)->replaceAccessControl(aclList);
ret = true;
}
+ else if ( dbComponent == "syncrepl" )
+ {
+ YCPMap argMap = arg->asMap();
+ if ( argMap->size() > 0 )
+ {
+ ret = true;
+ OlcSyncReplList srl = (*i)->getSyncRepl();
+ boost::shared_ptr<OlcSyncRepl> sr;
+ if ( srl.empty() )
+ {
+ sr = boost::shared_ptr<OlcSyncRepl>(new
OlcSyncRepl());
+ srl.push_back(sr);
+ }
+ else
+ {
+ sr = *srl.begin();
+ }
+ YCPMap providerMap =
argMap->value(YCPString("provider"))->asMap();
+ std::string protocol(
providerMap->value(YCPString("protocol"))->asString()->value_cstr() );
+ std::string target(
providerMap->value(YCPString("target"))->asString()->value_cstr() );
+ int port =
providerMap->value(YCPString("port"))->asInteger()->value();
+ std::string type(
argMap->value(YCPString("type"))->asString()->value_cstr() );
+ std::string basedn(
argMap->value(YCPString("basedn"))->asString()->value_cstr() );
+ std::string binddn(
argMap->value(YCPString("binddn"))->asString()->value_cstr() );
+ std::string cred(
argMap->value(YCPString("credentials"))->asString()->value_cstr() );
+ bool starttls =
argMap->value(YCPString("starttls"))->asBoolean()->value();
+
+ LDAPUrl prvuri;
+ prvuri.setScheme(protocol);
+ prvuri.setHost(target);
+ prvuri.setPort(port);
+
+ sr->setType( type );
+ sr->setProvider( prvuri );
+ sr->setSearchBase( basedn );
+ sr->setBindDn( binddn );
+ sr->setCredentials( cred );
+ // default retry (every 120 seconds)
+ sr->setRetryString( "120 +" );
+
+ if ( starttls )
+ {
+ sr->setStartTls( OlcSyncRepl::StartTlsCritical
);
+ }
+ else
+ {
+ sr->setStartTls( OlcSyncRepl::StartTlsNo );
+ }
+
+ if ( type == "refreshOnly" )
+ {
+ if (
argMap->value(YCPString("interval")).isNull() )
+ {
+ lastError->add(YCPString("summary"),
YCPString("Writing SyncRepl config failed") );
+ lastError->add(YCPString("description"),
YCPString("\"RefreshOnly needs Interval\"") );
+ ret = false;
+ }
+ else
+ {
+ YCPMap ivMap =
argMap->value(YCPString("interval"))->asMap();
+ int days =
ivMap->value(YCPString("days"))->asInteger()->value();
+ int hours =
ivMap->value(YCPString("hours"))->asInteger()->value();
+ int mins =
ivMap->value(YCPString("mins"))->asInteger()->value();
+ int secs =
ivMap->value(YCPString("secs"))->asInteger()->value();
+
+ if ( days == 0 && hours == 0 && mins == 0
&& secs == 0 )
+ {
+ lastError->add(YCPString("summary"),
YCPString("Writing SyncRepl config failed") );
+
lastError->add(YCPString("description"), YCPString("\"Syncrepl Interval is
00:00:00\"") );
+ ret = false;
+ }
+ else
+ {
+ sr->setInterval( days, hours, mins,
secs );
+ }
+ }
+ }
+ (*i)->setSyncRepl(srl);
+ if (
argMap->value(YCPString("updateref")).isNull() )
+ {
+ // set provider URL as updateref if no
customer URI was supplied
+ (*i)->setStringValue("olcUpdateRef",
prvuri.getURLString() );
+ }
+ else
+ {
+ YCPMap updaterefMap =
argMap->value(YCPString("updateref"))->asMap();
+ LDAPUrl updaterefUrl;
+ updaterefUrl.setScheme(
updaterefMap->value(YCPString("protocol"))->asString()->value_cstr() );
+ updaterefUrl.setHost(
updaterefMap->value(YCPString("target"))->asString()->value_cstr() );
+ updaterefUrl.setPort(
updaterefMap->value(YCPString("port"))->asInteger()->value() );
+ (*i)->setStringValue("olcUpdateRef",
updaterefUrl.getURLString() );
+ }
+ }
+ else
+ {
+ // clear syncrepl config
+ (*i)->setStringValue("olcSyncRepl", "" );
+ (*i)->setStringValue("olcUpdateRef", "" );
+ ret = true;
+ }
+ }
else if ( dbComponent == "dbconfig" )
{
YCPList argList = arg->asList();
@@ -1720,3 +1901,139 @@
return YCPString(ldif.str());
}

+static void initLdapParameters( const YCPValue &arg, std::string &targetUrl,
+ bool &starttls, std::string &binddn, std::string &bindpw, std::string
&basedn);
+bool SlapdConfigAgent::remoteBindCheck( const YCPValue &arg )
+{
+ y2milestone("remoteBindCheck");
+ std::string targetUrl, binddn, bindpw, basedn;
+ bool starttls;
+ initLdapParameters(arg, targetUrl ,starttls, binddn, bindpw, basedn);
+ try
+ {
+ LDAPConnection c( targetUrl );
+ if (starttls)
+ {
+ startTlsCheck(c);
+ }
+ bindCheck(c, binddn, bindpw);
+ }
+ catch( LDAPException e )
+ {
+ std::string details = e.getResultMsg();
+ if (! e.getServerMsg().empty() )
+ {
+ details += ": ";
+ details += e.getServerMsg();
+ }
+ lastError->add(YCPString("description"), YCPString( details ) );
+ y2milestone("Error connecting to the LDAP Server \"%s\". %s: %s",
+ targetUrl.c_str(),
+
lastError->value(YCPString("summary"))->asString()->value_cstr(),
+ details.c_str());
+ return false;
+ }
+ return true;
+}
+
+bool SlapdConfigAgent::remoteSyncCheck( const YCPValue &arg )
+{
+ y2milestone("remoteBindCheck");
+ std::string targetUrl, binddn, bindpw, basedn;
+ bool starttls;
+ initLdapParameters(arg, targetUrl ,starttls, binddn, bindpw, basedn);
+ try
+ {
+ LDAPConnection c( targetUrl );
+ if (starttls)
+ {
+ startTlsCheck(c);
+ }
+ bindCheck(c, binddn, bindpw);
+ syncCheck(c, basedn );
+ }
+ catch( LDAPException e )
+ {
+ std::string details = e.getResultMsg();
+ if (! e.getServerMsg().empty() )
+ {
+ details += ": ";
+ details += e.getServerMsg();
+ }
+ lastError->add(YCPString("description"), YCPString( details ) );
+ y2milestone("Error connection to the LDAP Server \"%s\". %s: %s",
+ targetUrl.c_str(),
+
lastError->value(YCPString("summary"))->asString()->value_cstr(),
+ details.c_str());
+ return false;
+ }
+ return true;
+}
+
+void initLdapParameters( const YCPValue &arg,
+ std::string &url,
+ bool &starttls,
+ std::string &binddn,
+ std::string &bindpw,
+ std::string &basedn)
+{
+ YCPMap argMap = arg->asMap();
+ YCPMap target = argMap->value(YCPString("target"))->asMap();
+ LDAPUrl targetUrl;
+ targetUrl.setScheme(
target->value(YCPString("protocol"))->asString()->value_cstr() );
+ targetUrl.setHost(
target->value(YCPString("target"))->asString()->value_cstr() );
+ targetUrl.setPort( target->value(YCPString("port"))->asInteger()->value()
);
+ url = targetUrl.getURLString();
+ starttls = argMap->value(YCPString("starttls"))->asBoolean()->value();
+ binddn = argMap->value(YCPString("binddn"))->asString()->value_cstr();
+ bindpw = argMap->value(YCPString("credentials"))->asString()->value_cstr();
+ basedn = argMap->value(YCPString("basedn"))->asString()->value_cstr();
+}
+
+// FIXME:
+// Until the TLS parameters can't be setup correctly with LDAPC++
+// the start_tls check might return false positives
+//
+void SlapdConfigAgent::startTlsCheck( LDAPConnection &c)
+{
+ try {
+ c.start_tls();
+ }
+ catch( LDAPException e )
+ {
+ lastError->add(YCPString("summary"), YCPString("StartTLS operation
failed") );
+ throw;
+ }
+}
+
+void SlapdConfigAgent::bindCheck( LDAPConnection &c, const std::string
&binddn, const std::string &bindpw)
+{
+ try {
+ c.bind(binddn, bindpw);
+ }
+ catch( LDAPException e )
+ {
+ lastError->add(YCPString("summary"), YCPString("LDAP authentication
failed") );
+ throw;
+ }
+}
+
+void SlapdConfigAgent::syncCheck( LDAPConnection &c, const std::string &basedn
)
+{
+ try{
+ // Simple LDAPSync Request Control (refreshOnly, no cookie)
+ const char ctrl[] = { 0x30, 0x03, 0x0a, 0x01, 0x01 };
+ LDAPCtrl syncCtrl( "1.3.6.1.4.1.4203.1.9.1.1", true, ctrl,
sizeof(ctrl) );
+ LDAPControlSet cs;
+ cs.add(syncCtrl);
+ LDAPConstraints searchCons;
+ searchCons.setServerControls( &cs );
+ c.search(basedn, LDAPConnection::SEARCH_BASE, "(objectclass=*)",
+ StringList(), false, &searchCons );
+ }
+ catch( LDAPException e )
+ {
+ lastError->add(YCPString("summary"), YCPString("Initiating the
LDAPsync Operation failed") );
+ throw;
+ }
+}

Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfigAgent.h?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/agent/SlapdConfigAgent.h (original)
+++ trunk/ldap-server/src/agent/SlapdConfigAgent.h Tue Feb 9 17:23:31 2010
@@ -68,6 +68,14 @@
const YCPValue &arg = YCPNull(),
const YCPValue &opt = YCPNull());
YCPString ConfigToLdif() const;
+ bool remoteBindCheck( const YCPValue &arg );
+ bool remoteSyncCheck( const YCPValue &arg );
+ void startTlsCheck( LDAPConnection &c);
+ void bindCheck( LDAPConnection &c,
+ const std::string &binddn,
+ const std::string &bindpw);
+ void syncCheck( LDAPConnection &c,
+ const std::string &basedn );

private:
YCPMap lastError;

Modified: trunk/ldap-server/src/dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/dialogs.ycp?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/dialogs.ycp (original)
+++ trunk/ldap-server/src/dialogs.ycp Tue Feb 9 17:23:31 2010
@@ -92,7 +92,10 @@
{
if( !(boolean)eval( function ) )
{
- Report::Error( callback_error );
+ if (callback_error != "" )
+ {
+ Report::Error( callback_error );
+ }
return false;
}
} else {
@@ -117,7 +120,12 @@
else if ( !LdapServer::ReadServiceRunning() )
{
if ( name != "daemon" ) {
- symbol ret = Popup::AnyQuestion3( _("The LDAP Server is not
running."), _("Do you want to start it now to re-read its configuration data or
do you want to creat a new configuration from scratch?"), _("Restart"), _("New
Configuration"), Label::AbortButton(), `focus_yes );
+ symbol ret = Popup::AnyQuestion3( _("The LDAP Server is not
running."),
+ _("Do you want to start it now to re-read its
configuration data or do you want to creat a new configuration from scratch?"),
+ _("Restart"),
+ _("New Configuration"),
+ Label::AbortButton(),
+ `focus_yes );
name = "daemon";
if ( ret == `yes )
{
@@ -201,7 +209,9 @@
map<string, any> firewall_widget =
CWMFirewallInterfaces::CreateOpenFirewallWidget (firewall_settings);

- Wizard::SetContentsButtons( caption, dlg_service_initial,
HELPS["service_dialog"]:"help not found", Label::BackButton(),
Label::NextButton() );
+ Wizard::SetContentsButtons( caption, dlg_service_initial,
+ HELPS["service_dialog"]:"help not found",
+ Label::BackButton(), Label::NextButton() );
Wizard::HideBackButton();
Wizard::SetAbortButton(`abort, Label::CancelButton());

@@ -264,7 +274,11 @@

any TlsConfigDialog()
{
- Wizard::SetContentsButtons( caption, tlsWidget, HELPS["tls_dialog"]:"help
not found", Label::BackButton(), Label::NextButton() );
+ Wizard::SetContentsButtons( caption,
+ tlsWidget,
+ HELPS["tls_dialog"]:"help not found",
+ Label::BackButton(),
+ Label::NextButton() );
LdapServer::InitGlobals();
cb_read_tls();
any ret = nil;

Modified: trunk/ldap-server/src/lib/slapd-config.cpp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/lib/slapd-config.cpp?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/lib/slapd-config.cpp (original)
+++ trunk/ldap-server/src/lib/slapd-config.cpp Tue Feb 9 17:23:31 2010
@@ -12,6 +12,7 @@
#include <LDAPResult.h>
#include <string>
#include <iostream>
+#include <iomanip>
#include <sstream>
#include <map>
#include <vector>
@@ -832,6 +833,262 @@
return aclString.str();
}

+const std::string OlcSyncRepl::RID="rid";
+const std::string OlcSyncRepl::PROVIDER="provider";
+const std::string OlcSyncRepl::BASE="searchbase";
+const std::string OlcSyncRepl::TYPE="type";
+const std::string OlcSyncRepl::BINDMETHOD="bindmethod";
+const std::string OlcSyncRepl::BINDDN="binddn";
+const std::string OlcSyncRepl::CREDENTIALS="credentials";
+const std::string OlcSyncRepl::INTERVAL="interval";
+const std::string OlcSyncRepl::STARTTLS="starttls";
+const std::string OlcSyncRepl::RETRY="retry";
+
+OlcSyncRepl::OlcSyncRepl( const std::string &syncreplLine):
+ rid(1),
+ bindmethod("simple"),
+ starttls( OlcSyncRepl::StartTlsNo )
+{
+ log_it(SLAPD_LOG_DEBUG, "OlcSyncRepl::OlcSyncRepl(" + syncreplLine + ")");
+ if ( !syncreplLine.empty() )
+ {
+ std::string::size_type spos1=0, spos2=0;
+
+ // skip leading whitespaces
+ spos2 = syncreplLine.find_first_not_of("\t ", spos1 );
+ while ( spos2 != std::string::npos && spos2 >= spos1 )
+ {
+ spos1 = spos2;
+ spos2 = syncreplLine.find_first_of("=", spos1 );
+ std::string key = syncreplLine.substr(spos1, spos2-spos1);
+ log_it(SLAPD_LOG_INFO, "Key: <" + key + ">");
+ spos1 = spos2 + 1;
+ spos2 = extractAlcToken(syncreplLine, spos1, true );
+ std::string value = syncreplLine.substr(spos1, spos2-spos1);
+ log_it(SLAPD_LOG_INFO, "Value: <" + value + ">");
+ if ( spos2 != std::string::npos )
+ {
+ spos1 = spos2 + 1;
+ spos2 = syncreplLine.find_first_not_of("\t ", spos1 );
+ }
+ if ( key == RID )
+ {
+ std::istringstream s(value);
+ s >> rid;
+ }
+ else if ( key == PROVIDER )
+ {
+ this->setProvider(value);
+ }
+ else if ( key == BASE )
+ {
+ this->setSearchBase(value);
+ }
+ else if ( key == TYPE )
+ {
+ this->setType(value);
+ }
+ else if ( key == BINDMETHOD )
+ {
+ if ( value != "simple" )
+ {
+ log_it(SLAPD_LOG_ERR, "Bind method " + value + " is
currenty unsupported" );
+ throw std::runtime_error( "Bind method " + value + " is
currenty unsupported" );
+ }
+ }
+ else if ( key == BINDDN )
+ {
+ this->setBindDn(value);
+ }
+ else if ( key == CREDENTIALS )
+ {
+ this->setCredentials(value);
+ }
+ else if ( key == INTERVAL )
+ {
+ istringstream intervalStr(value);
+
+ intervalStr.exceptions( std::ios::failbit | std::ios::badbit );
+ try
+ {
+ intervalStr >> refreshOnlyDays;
+ intervalStr.get();
+ intervalStr >> refreshOnlyHours;
+ intervalStr.get();
+ intervalStr >> refreshOnlyMins;
+ intervalStr.get();
+ intervalStr >> refreshOnlySecs;
+ }
+ catch ( std::exception e)
+ {
+ log_it(SLAPD_LOG_ERR, "Error parsing replication
interval:\"" + value + "\"" );
+ log_it(SLAPD_LOG_ERR, e.what() );
+ throw std::runtime_error( "Error parsing replication
interval:\"" + value + "\"" );
+ }
+ }
+ else if ( key == STARTTLS )
+ {
+ if ( value == "critical" )
+ {
+ this->setStartTls(OlcSyncRepl::StartTlsCritical);
+ }
+ else if ( value == "yes" )
+ {
+ this->setStartTls(OlcSyncRepl::StartTlsYes);
+ }
+ }
+ else if ( key == RETRY )
+ {
+ this->setRetryString(value);
+ }
+ else
+ {
+ otherValues.push_back(make_pair(key, value));
+ }
+ }
+ }
+}
+
+std::string OlcSyncRepl::toSyncReplLine() const
+{
+ std::ostringstream srlStream;
+
+ srlStream << "rid=" << rid << " "
+ << "provider=\"" << provider.getURLString() << "\" "
+ << "searchbase=\"" << this->searchbase << "\" "
+ << "type=\"" << this->type << "\" "
+ << "retry=\"" << this->retryString << "\" ";
+
+ if ( this->type == "refreshOnly" )
+ {
+ srlStream << "interval=\"" << std::setw(2) << std::setfill('0') <<
refreshOnlyDays << ":"
+ << std::setw(2) << std::setfill('0') <<
refreshOnlyHours << ":"
+ << std::setw(2) << std::setfill('0') <<
refreshOnlyMins << ":"
+ << std::setw(2) << std::setfill('0') <<
refreshOnlySecs << "\" ";
+ }
+ if ( this->starttls == OlcSyncRepl::StartTlsYes )
+ {
+ srlStream << "starttls=yes ";
+ }
+ else if ( this->starttls == OlcSyncRepl::StartTlsCritical )
+ {
+ srlStream << "starttls=critical ";
+ }
+ srlStream << "bindmethod=\"" << this->bindmethod << "\" "
+ << "binddn=\"" << this->binddn << "\" "
+ << "credentials=\"" << this->credentials << "\"";
+
+ std::vector<std::pair<std::string,std::string> >::const_iterator i;
+ for ( i = otherValues.begin(); i != otherValues.end(); i++ )
+ {
+ srlStream << " " << i->first << "=\"" << i->second << "\"";
+ }
+
+ return srlStream.str();
+}
+
+void OlcSyncRepl::setRid( int value )
+{
+ rid = value;
+}
+
+void OlcSyncRepl::setProvider( const std::string &value )
+{
+ provider = LDAPUrl(value);
+}
+
+void OlcSyncRepl::setProvider( const LDAPUrl &value )
+{
+ provider = value;
+}
+
+void OlcSyncRepl::setType( const std::string &value )
+{
+ type = value;
+}
+
+void OlcSyncRepl::setSearchBase( const std::string &value )
+{
+ searchbase = value;
+}
+
+void OlcSyncRepl::setBindDn( const std::string &value )
+{
+ binddn = value;
+}
+
+void OlcSyncRepl::setCredentials( const std::string &value )
+{
+ credentials = value;
+}
+
+void OlcSyncRepl::setInterval( int days, int hours, int mins, int secs )
+{
+ refreshOnlyDays = days;
+ refreshOnlyHours = hours;
+ refreshOnlyMins = mins;
+ refreshOnlySecs = secs;
+}
+
+void OlcSyncRepl::setStartTls( OlcSyncRepl::StartTls value )
+{
+ starttls = value;
+}
+
+void OlcSyncRepl::setRetryString( const std::string &value )
+{
+ retryString = value;
+}
+
+int OlcSyncRepl::getRid() const
+{
+ return rid;
+}
+
+LDAPUrl OlcSyncRepl::getProvider() const
+{
+ return provider;
+}
+
+void OlcSyncRepl::getProviderComponents( std::string &proto, std::string
&target, int &port) const
+{
+ proto = provider.getScheme();
+ target = provider.getHost();
+ port = provider.getPort();
+}
+
+std::string OlcSyncRepl::getType() const
+{
+ return type;
+}
+
+std::string OlcSyncRepl::getSearchBase() const
+{
+ return searchbase;
+}
+
+std::string OlcSyncRepl::getBindDn() const
+{
+ return binddn;
+}
+
+std::string OlcSyncRepl::getCredentials() const
+{
+ return credentials;
+}
+
+void OlcSyncRepl::getInterval( int &days, int &hours, int &mins, int &secs )
const
+{
+ days = refreshOnlyDays;
+ hours = refreshOnlyHours;
+ mins = refreshOnlyMins;
+ secs = refreshOnlySecs;
+}
+
+OlcSyncRepl::StartTls OlcSyncRepl::getStartTls() const
+{
+ return starttls;
+}

OlcDatabase::OlcDatabase( const LDAPEntry& le=LDAPEntry()) : OlcConfigEntry(le)
{
@@ -944,6 +1201,62 @@
}
}

+
+OlcSyncReplList OlcDatabase::getSyncRepl() const
+{
+ const LDAPAttribute* srAttr =
m_dbEntryChanged.getAttributeByName("olcSyncrepl");
+ OlcSyncReplList res;
+
+ if (! srAttr )
+ {
+ return res;
+ }
+
+ StringList values = srAttr->getValues();
+ if ( values.size() != 1 )
+ {
+ log_it(SLAPD_LOG_ERR, "Multiple syncrepl statements");
+ }
+ else
+ {
+ std::string syncreplLine;
+ splitIndexFromString( *values.begin(), syncreplLine );
+ try {
+ boost::shared_ptr<OlcSyncRepl> syncrepl( new
OlcSyncRepl(syncreplLine) );
+ res.push_back(syncrepl);
+ }
+ catch ( std::runtime_error e )
+ {
+ log_it(SLAPD_LOG_INFO, "Can't parse Syncrepl line");
+ log_it(SLAPD_LOG_INFO, e.what() );
+ throw;
+ }
+ }
+ return res;
+}
+
+void OlcDatabase::addSyncRepl(const std::string& value, int index )
+{
+ if ( index < 0 )
+ {
+ StringList sl = this->getStringValues( "olcSyncrepl" );
+ index = sl.size();
+ }
+ this->addIndexedStringValue( "olcSyncrepl", value, index );
+}
+
+void OlcDatabase::setSyncRepl( const OlcSyncReplList& srl )
+{
+ this->setStringValue("olcSyncRepl", "" );
+
+ OlcSyncReplList::const_iterator i;
+ int j = 0;
+ for ( i = srl.begin(); i != srl.end(); i++,j++ )
+ {
+ this->addSyncRepl( (*i)->toSyncReplLine(), j );
+ }
+}
+
void OlcDatabase::addOverlay(boost::shared_ptr<OlcOverlay> overlay)
{
m_overlays.push_back(overlay);

Modified: trunk/ldap-server/src/lib/slapd-config.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/lib/slapd-config.h?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/lib/slapd-config.h (original)
+++ trunk/ldap-server/src/lib/slapd-config.h Tue Feb 9 17:23:31 2010
@@ -13,6 +13,7 @@
#define BACK_CONFIG_TEST_H
#include <LDAPConnection.h>
#include <LDAPResult.h>
+#include <LDAPUrl.h>
#include <string>
#include <iostream>
#include <sstream>
@@ -230,8 +231,71 @@
OlcAclByList m_byList;
};

+class OlcSyncRepl
+{
+ public:
+ enum StartTls {
+ StartTlsNo,
+ StartTlsYes,
+ StartTlsCritical
+ };
+
+ OlcSyncRepl( const std::string &syncreplLine="" );
+ const static std::string RID;
+ const static std::string PROVIDER;
+ const static std::string BASE;
+ const static std::string TYPE;
+ const static std::string BINDMETHOD;
+ const static std::string BINDDN;
+ const static std::string CREDENTIALS;
+ const static std::string INTERVAL;
+ const static std::string STARTTLS;
+ const static std::string RETRY;
+
+ std::string toSyncReplLine() const;
+
+ void setRid( int value );
+ void setProvider( const std::string &value );
+ void setProvider( const LDAPUrl &value );
+ void setType( const std::string &value );
+ void setSearchBase( const std::string &value );
+ void setBindDn( const std::string &value );
+ void setCredentials( const std::string &value );
+ void setInterval( int days, int hours, int mins, int secs );
+ void setStartTls( StartTls tls );
+ void setRetryString( const std::string &value );
+
+ int getRid() const;
+ LDAPUrl getProvider() const;
+ void getProviderComponents( std::string &proto, std::string &target,
int &port) const;
+ std::string getType() const;
+ std::string getSearchBase() const;
+ std::string getBindDn() const;
+ std::string getCredentials() const;
+ void getInterval( int &days, int &hours, int &mins, int &secs ) const;
+ StartTls getStartTls() const;
+
+ private:
+ int rid;
+ LDAPUrl provider;
+ std::string type;
+ std::string searchbase;
+ std::string bindmethod;
+ std::string binddn;
+ std::string credentials;
+ std::string retryString;
+ int refreshOnlyDays;
+ int refreshOnlyHours;
+ int refreshOnlyMins;
+ int refreshOnlySecs;
+ std::vector<std::pair<std::string, std::string> > otherValues;
+ StartTls starttls;
+};
+
typedef std::list<boost::shared_ptr<OlcOverlay> > OlcOverlayList;
typedef std::list<boost::shared_ptr<OlcAccess> > OlcAccessList;
+typedef std::list<boost::shared_ptr<OlcSyncRepl> > OlcSyncReplList;
+
class OlcDatabase : public OlcConfigEntry
{
public :
@@ -250,10 +314,13 @@
const std::string getType() const;

bool getAcl( OlcAccessList& accessList ) const;
-
virtual void addAccessControl( const std::string& acl, int index=-1 );
virtual void replaceAccessControl( const OlcAccessList& acllist );

+ OlcSyncReplList getSyncRepl() const;
+ void setSyncRepl( const OlcSyncReplList& srl );
+ void addSyncRepl( const std::string& value, int index=-1 );
+
void addOverlay(boost::shared_ptr<OlcOverlay> overlay);
OlcOverlayList& getOverlays() ;


Modified: trunk/ldap-server/src/tree_structure.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/tree_structure.ycp?rev=60777&r1=60776&r2=60777&view=diff
==============================================================================
--- trunk/ldap-server/src/tree_structure.ycp (original)
+++ trunk/ldap-server/src/tree_structure.ycp Tue Feb 9 17:23:31 2010
@@ -872,6 +872,55 @@
return result;
}

+define boolean cb_read_synccons()
+{
+ y2milestone("cb_read_synccons()");
+ string treeItem = current_tree_item;
+ integer index = (integer)widget_map[current_tree_item,"index"]:nil;
+ map<string,any> sr = LdapServer::ReadSyncRepl(index);
+ y2milestone("cb_read_synccons() %1", sr);
+ if ( sr == nil )
+ {
+ map<string, string> err = LdapServer::ReadError();
+ callback_error = err["msg"]:"" + "\n" + err["details"]:"";
+ }
+ else
+ {
+ return LdapDatabase::DbSyncConsRead( handler_cmd, index, sr );
+ }
+}
+
+define boolean cb_input_synccons()
+{
+ y2milestone("cb_input_synccons()");
+ string treeItem = current_tree_item;
+ integer index = (integer)widget_map[current_tree_item,"index"]:nil;
+ return LdapDatabase::DbSyncConsInput( handler_cmd, index );
+}
+
+define boolean cb_check_synccons()
+{
+ y2milestone("cb_check_synccons()");
+ string treeItem = current_tree_item;
+ integer index = (integer)widget_map[current_tree_item,"index"]:nil;
+ return LdapDatabase::DbSyncConsCheck( index );
+}
+
+define boolean cb_write_synccons()
+{
+ y2milestone("cb_write_synccons()");
+ string treeItem = current_tree_item;
+ integer index = (integer)widget_map[current_tree_item,"index"]:nil;
+ map <string,any> syncrepl = LdapDatabase::DbSyncConsWrite( index );
+ boolean result = false;
+ result = LdapServer::WriteSyncRepl(index, syncrepl);
+ if ( ! result ) {
+ map<string, string> err = LdapServer::ReadError();
+ callback_error = err["msg"]:"" + "\n" + err["details"]:"";
+ }
+ return result;
+}
+
define boolean cb_input_ppolicy()
{
y2milestone("cb_input_ppolicy()");
@@ -1029,6 +1078,16 @@
"cb_input" : ``(cb_input_syncprov() ),
"help_page" : "syncprov_edit"
];
+ map<string, any> dbSyncCons = $[
+ "name" : _("Replication Consumer"),
+ "widget" : LdapDatabase::GetSyncConsWidget(),
+ "index" : index,
+ "cb_read" : ``(cb_read_synccons() ),
+ "cb_write" : ``(cb_write_synccons() ),
+ "cb_input" : ``(cb_input_synccons() ),
+ "cb_check" : ``( cb_check_synccons() ),
+ "help_page" : "synccons_edit"
+ ];
map<string,any> item_map = $[
"name" : label,
"children" : [ item_name + "_acl"],
@@ -1040,7 +1099,8 @@
];
map<string,any> bdb_item_map = $[
"name" : label,
- "children" : [ item_name + "_index", item_name + "_ppolicy",
item_name + "_acl", item_name + "_syncprov"],
+ "children" : [ item_name + "_index", item_name + "_ppolicy",
item_name + "_acl",
+ item_name + "_syncprov", item_name + "_synccons" ],
"index" : index,
"widget" : editBdbDatabase,
"new_db" : new_db,
@@ -1052,7 +1112,7 @@
];
map<string,any> confdb_item_map = $[
"name" : label,
- "children" : [ item_name + "_acl", item_name + "_syncprov"],
+ "children" : [ item_name + "_acl", item_name + "_syncprov", item_name
+ "_synccons" ],
"index" : index,
"widget" : editGenericDatabase,
"new_db" : new_db,
@@ -1068,12 +1128,14 @@
widget_map[item_name + "_ppolicy"] = dbPpolicy;
widget_map[item_name + "_acl"] = dbAcl;
widget_map[item_name + "_syncprov"] = dbSyncProv;
+ widget_map[item_name + "_synccons"] = dbSyncCons;
}
else if ( type == "config" )
{
widget_map[item_name] = confdb_item_map;
widget_map[item_name + "_acl"] = dbAcl;
widget_map[item_name + "_syncprov"] = dbSyncProv;
+ widget_map[item_name + "_synccons"] = dbSyncCons;
}
else
{

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages