ACC SHELL

Path : /usr/share/YaST2/clients/
File Upload :
Current File : //usr/share/YaST2/clients/ldap.ycp

/**
 * File:	clients/ldap.ycp
 * Module:	Configuration of LDAP client
 * Summary:	Client file, including commandline handlers
 * Authors:	Thorsten Kukuk <kukuk@suse.de>
 *		Anas Nashif <nashif@suse.de>
 *
 * $Id: ldap.ycp 47528 2008-05-14 13:14:51Z jsuchome $
 */

/***
 * <h3>Configuration of the ldap</h3>
 */

{

    textdomain "ldap-client";

    import "CommandLine";
    import "Ldap";
    import "RichText";
    import "Service";

    include "ldap/wizards.ycp";

    any ret = `auto;

// --------------------------------------------------------------------------
// --------------------------------- cmd-line handlers

/**
 * Print summary of basic options
 * @return boolean false
 */
define boolean LdapSummaryHandler (map options ) ``{

    CommandLine::Print (RichText::Rich2Plain ("<br>" + Ldap::ShortSummary ()));
    return false; // do not call Write...
}

/**
 * Change basic configuration of LDAP client (server, base DN)
 * @param options  a list of parameters passed as args
 * @return boolean true on success
 */
define boolean LdapChangeConfiguration (map<string, string> options ) ``{

    string server = options["server"]:"";
    if( server != "" )
    {
	Ldap::server	= server;
	Ldap::modified	= true;
    }
    string base = options["base"]:"";
    if( base != "" )
    {
	Ldap::SetDomain (base);
	Ldap::modified	= true;
    }

    string ldappw = options["ldappw"]:"";
    if( ldappw != "" )
    {
        Ldap::bind_pass = ldappw;
        Ldap::modified  = true;
    }
    if (options["automounter"]:"" == "yes" && !Ldap::_start_autofs)
    {
	Ldap::_start_autofs	= true;
	Ldap::modified		= true;
    }
    if (options["automounter"]:"" == "no" && Ldap::_start_autofs)
    {
	Ldap::_start_autofs	= false;
	Ldap::modified		= true;
    }
    if (options["mkhomedir"]:"" != "")
    {
	boolean mkhomedir	= (options["mkhomedir"]:"" == "yes");
	if (Ldap::mkhomedir != mkhomedir)
	{
	    Ldap::mkhomedir	= mkhomedir;
	    Ldap::modified	= true;
	}
    }
    if (options["tls"]:"" != "")
    {
	boolean tls		= (options["tls"]:"" == "yes");
	if (Ldap::ldap_tls	!= tls)
	{
	    Ldap::ldap_tls	= tls;
	    Ldap::modified	= true;
	}
    }

    if (haskey (options, "createconfig"))
    {
	if (Ldap::bind_pass == nil)
	{
	    // password entering label
	    Ldap::bind_pass = CommandLine::PasswordInput (_("LDAP Server Password:"));
	}
	Ldap::create_ldap = true;
        Ldap::modified  = true;
    }

    return Ldap::modified;
}

/**
 * Enable or disable LDAP authentication
 * @param options  a list of parameters passed as args
 * @return boolean true on success
 */
define boolean LdapEnableHandler( map<string,string> options ) ``{
    // check the "command" to be present exactly once
    string command = CommandLine::UniqueOption( options,
	["enable", "disable" ] );
    if( command == nil ) return false;

    Ldap::RestartSSHD (
	command == "enable" && !Ldap::start && Service::Status ("sshd") == 0);

    if ((Ldap::start && command == "disable") ||
	(!Ldap::start && command == "enable"))
	Ldap::modified	= true;

    Ldap::start = ( command == "enable" );

    return LdapChangeConfiguration (options);
}


/* the command line description map */
map cmdline = $[
    "id"		: "ldap",
    // translators: command line help text for Ldap client module
    "help"		: _("LDAP client configuration module"),
    "guihandler"	: LdapSequence,
    "initialize"	: Ldap::Read,
    "finish"		: Ldap::WriteNow,
    "actions"		: $[
	"pam" :$[
	    "handler"	: LdapEnableHandler,
	    // translators: command line help text for pam action
	    "help"	: _("Enable or disable authentication with LDAP")
	],
	"summary" :$[
	    "handler"	: LdapSummaryHandler,
	    // translators: command line help text for summary action
	    "help"	: _("Configuration summary of the LDAP client")
	],
	"configure"	: $[
	    "handler"	: LdapChangeConfiguration,
	    // translators: command line help text for configure action
	    "help"	: _("Change the global settings of the LDAP client")
	]
    ],
    "options"		: $[
	"enable"	:$[
	    // translators: command line help text for pam enable option
	    "help"	: _("Enable the service")
	],
	"disable"	:$[
	    // translators: command line help text for pam disable option
	    "help"	: _("Disable the service")
	],
	"server"	:$[
	    // translators: command line help text for the server option
	    "help"	: _("The LDAP server name"),
	    "type"	: "string"
	],
	"base"	:$[
	    // translators: command line help text for the base option
	    "help"	: _("Distinguished name (DN) of the search base"),
	    "type"	: "string"
	],
	"createconfig"  :$[
	    // command line help text for the 'createconfig' option
	   "help"       : _("Create default configuration objects.")
	],
	"ldappw"	:$[
	    // command line help text for the 'ldappw' option
	   "help"	: _("LDAP Server Password"),
	   "type"       : "string"
	],
	"automounter"	:$[
	    // help text for the 'automounter' option
	    "help"	: _("Start or stop automounter"),
	    "type"	: "enum",
	    "typespec"  : [ "yes", "no" ],
	],
	"mkhomedir"	: $[
	    // help text for the 'mkhomedir' option
	    "help"	: _("Create Home Directory on Login"),
	    "type"	: "enum",
	    "typespec"  : [ "yes", "no" ],
	],
	"tls"	: $[
	    // help text for the 'tls' option
	    "help"	: _("Encrypted connection (StartTLS)"),
	    "type"	: "enum",
	    "typespec"  : [ "yes", "no" ],
	],
    ],
    "mappings"		: $[
	"pam"		: [ "enable", "disable", "server", "base",
	    "createconfig", "ldappw", "automounter", "mkhomedir", "tls"
	],
	"summary"	: [],
	"configure"	: [ "server", "base", "createconfig", "ldappw",
	    "automounter", "mkhomedir", "tls"
	],
    ]
];

   ret = CommandLine::Run( cmdline );
   return ret;
}

ACC SHELL 2018