ACC SHELL

Path : /proc/self/root/usr/share/YaST2/include/ldap/
File Upload :
Current File : //proc/self/root/usr/share/YaST2/include/ldap/routines.ycp

/**
 * File:	include/ldap/routines.ycp
 * Package:	Configuration of LDAP
 * Summary:	Helper routines for string manupulations
 * Authors:	Jiri Suchomel <jsuchome@suse.cz>
 *
 * $Id: routines.ycp 31656 2006-06-26 07:46:55Z jsuchome $
 *
 */

{

textdomain "ldap-client";

import "Ldap";

/**
 * Get RDN (relative distinguished name) from dn
 */
define string get_rdn (string dn) ``{

    list dn_list = splitstring (dn, ",");
    return dn_list[0]:dn;
}

/**
 * Get first value from dn (don't have to be "cn")
 */
define string get_cn (string dn) ``{

    string rdn	= get_rdn (dn);
    return issubstring (rdn, "=") ? substring (rdn, search (rdn,"=") + 1) : rdn;
}

/**
 * Create DN from cn by adding base config DN
 * (Can't work in general cases!)
 */
define string get_dn (string cn) ``{

    return sformat ("cn=%1,%2", cn, Ldap::base_config_dn);
}

/**
 * Create new DN from DN by changing leading cn value
 * (Can't work in general cases!)
 */
define string get_new_dn (string cn, string dn) ``{

    return tolower (sformat ("cn=%1%2", cn,
	issubstring (dn, ",") ? substring (dn, search (dn, ",")) : ""));
}

/**
 * Get string value of attribute from map.
 * (Generaly, it is supposed to be list or string.)
 */
define string get_string (map object, string attr) ``{

    if (is (object [attr]:nil, list))
	return object [attr,0]:"";
    return (string) (object [attr]:"");
}

}

ACC SHELL 2018