Author: rhafer
Date: Wed Sep 10 17:11:48 2008
New Revision: 50979
URL: http://svn.opensuse.org/viewcvs/yast?rev=50979&view=rev
Log:
Re-import code for adding default policies (currenty disabled)
Modified:
trunk/ldap-server/src/LdapDatabase.ycp
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=50979&r1=50978&r2=50979&view=diff
==============================================================================
--- trunk/ldap-server/src/LdapDatabase.ycp (original)
+++ trunk/ldap-server/src/LdapDatabase.ycp Wed Sep 10 17:11:48 2008
@@ -3,6 +3,7 @@
module "LdapDatabase";
import "Label";
import "LdapServer";
+ import "Ldap";
import "LdapPopup";
import "Popup";
import "Sequencer";
@@ -57,7 +58,16 @@
)
),
`VSpacing( 0.3 )
+ // disabled, this doesn't work as desired
+ //),
+ //`HSpacing( 0.5 ),
+ //`VBox(
+ // `Bottom(
+ // `PushButton( `id( `pb_define_policy ), _("Edit Policy"))
+ // ),
+ // `VSpacing( 0.3 )
)
+
)
),
`VSpacing(0.25)
@@ -390,6 +400,7 @@
UI::ChangeWidget( `cb_ppolicy_overlay, `Value, false );
UI::ChangeWidget( `cb_ppolicy_hashcleartext, `Enabled , false );
UI::ChangeWidget( `cb_ppolicy_uselockout, `Enabled , false );
+ UI::ChangeWidget( `pb_define_policy, `Enabled , false );
UI::ChangeWidget( `te_ppolicy_defaultpolicy, `Enabled , false );
}
return true;
@@ -419,14 +430,14 @@
ppolicy = add( ppolicy, "useLockout", false);
}
if (pp_default != "" ) {
+ map db = baseDb;
+ if ( dbindex > 0 )
+ {
+ db = LdapServer::ReadDatabase(dbindex);
+ }
+ string suffix = db["suffix"]:"";
if( (boolean)UI::QueryWidget( `cb_pp_append_basedn, `Value ) )
{
- map db = baseDb;
- if ( dbindex > 0 )
- {
- db = LdapServer::ReadDatabase(dbindex);
- }
- string suffix = db["suffix"]:"";
pp_default = pp_default+","+suffix;
}
ppolicy = add( ppolicy, "defaultPolicy", pp_default);
@@ -442,19 +453,83 @@
}
}
- global boolean DbPpolicyInput( symbol handler_cmd )
+ global boolean DbPpolicyInput( symbol handler_cmd, integer dbindex )
{
- if ( handler_cmd == `cb_ppolicy_overlay ) {
+ if ( handler_cmd == `cb_ppolicy_overlay )
+ {
if ( UI::QueryWidget( `cb_ppolicy_overlay, `Value ) == true ) {
UI::ChangeWidget( `cb_ppolicy_hashcleartext, `Enabled , true );
UI::ChangeWidget( `cb_ppolicy_uselockout, `Enabled , true );
UI::ChangeWidget( `te_ppolicy_defaultpolicy, `Enabled , true );
UI::ChangeWidget( `cb_pp_append_basedn, `Enabled, true );
+ UI::ChangeWidget( `pb_define_policy, `Enabled , true );
} else {
UI::ChangeWidget( `cb_ppolicy_hashcleartext, `Enabled , false );
UI::ChangeWidget( `cb_ppolicy_uselockout, `Enabled , false );
UI::ChangeWidget( `te_ppolicy_defaultpolicy, `Enabled , false );
UI::ChangeWidget( `cb_pp_append_basedn, `Enabled, false );
+ UI::ChangeWidget( `pb_define_policy, `Enabled , false );
+ }
+ }
+ else if ( handler_cmd == `pb_define_policy )
+ {
+ string pp_default = (string)UI::QueryWidget( `te_ppolicy_defaultpolicy, `Value );
+ if ( dbindex > 0 )
+ {
+ map db = baseDb;
+ db = LdapServer::ReadDatabase(dbindex);
+ if( (boolean)UI::QueryWidget( `cb_pp_append_basedn, `Value ) )
+ {
+ pp_default = pp_default+","+db["suffix"]:"";
+ }
+
+ if ( dbindex > 0 )
+ {
+ // try to read ppolicy from Server
+ map ppolicyEntry = $[];
+ Ldap::Import( $[ "ldap_server" : "localhost",
+ "bind_dn" : db["rootdn"]:"" ] );
+ Ldap::LDAPInit();
+ string pw = "";
+ string bind_res = "tmp";
+ while( bind_res != "" ) {
+ if ( pw == "" ) {
+ pw = Ldap::GetLDAPPassword(false);
+ }
+ bind_res = Ldap::LDAPBind (pw);
+ if (bind_res != "" ) {
+ if (Popup::YesNo( _("Authentication failed. The password is probably incorrect.\n") +
+ _("The error message was: '") + bind_res + "'\n" +
+ _("Try again?") ) )
+ {
+ pw = "";
+ } else {
+ break;
+ }
+ }
+ }
+ if ( bind_res == "" )
+ {
+ list res = (list)SCR::Read (.ldap.search, $[ "base_dn" : pp_default,
+ "filter" : "objectclass=*",
+ "scope" : 0 ] );
+ if ( size(res) > 0 ) {
+ y2milestone("default_policy does already exist");
+ ppolicyEntry = (map)res[0]:nil;
+ }
+ else
+ {
+ y2milestone("default_policy does not yet exist");
+ }
+ ppolicyEntry = LdapPopup::PasswordPolicyDialog(ppolicyEntry);
+ if ( size( ppolicyEntry ) > 0 )
+ {
+ ppolicyEntry["objectClass"] = [ "namedObject", "pwdPolicy" ];
+ ppolicyEntry["pwdAttribute"] = [ "userPassword" ];
+ SCR::Write(.ldap.add, $[ "dn" : pp_default, "check_attrs" : "true"], ppolicyEntry );
+ }
+ }
+ }
}
}
return true;
@@ -1322,7 +1397,7 @@
}
else
{
- DbPpolicyInput(ret);
+ DbPpolicyInput(ret, -1);
}
}
return ret;
Modified: trunk/ldap-server/src/tree_structure.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/tree_structure.ycp?rev=50979&r1=50978&r2=50979&view=diff
==============================================================================
--- trunk/ldap-server/src/tree_structure.ycp (original)
+++ trunk/ldap-server/src/tree_structure.ycp Wed Sep 10 17:11:48 2008
@@ -811,9 +811,9 @@
define boolean cb_input_ppolicy()
{
y2milestone("cb_input_ppolicy()");
- string treeItem = current_tree_item;
- y2milestone( "calling db input handler for item '%1'", treeItem );
- return LdapDatabase::DbPpolicyInput( handler_cmd );
+ integer index = (integer)widget_map[current_tree_item,"index"]:nil;
+ y2milestone( "calling db input handler for item '%1'", current_tree_item );
+ return LdapDatabase::DbPpolicyInput( handler_cmd, index );
}
define boolean cb_read_ppolicy()
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org