<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Apéndice AJ. Archivo de configuración /var/www/phpldapadmin/templates/template_config.php</title><link rel="stylesheet" href="./estilo.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.64.1" /><link rel="home" href="index.html" title="Integración de redes con OpenLDAP, Samba, CUPS y PyKota" /><link rel="up" href="apendice-archivos-configuracion.html" title="Parte VI. Archivos de configuración" /><link rel="previous" href="phpldapadmin-config.php.html" title="Apéndice AI. Archivo de configuración /var/www/phpldapadmin/config.php" /><link rel="next" href="smbldap-tools-smbldap_conf.html" title="Apéndice AK. Archivo de configuración /etc/smbldap-tools/smbldap.conf" /><meta xmlns="http://www.w3.org/TR/xhtml1/transitional" name="generator" content="Experimental LDP.XSL $Revision: 1.3 $"></meta>
  <!-- Generated by LDP XSLT customization layer
      based on Norman Walsh's DocBook XSL stylesheets.
      More information at http://www.linuxdoc.org/ -->
  </head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Apéndice AJ. Archivo de configuración /var/www/phpldapadmin/templates/template_config.php</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="phpldapadmin-config.php.html">Anterior</a> </td><th width="60%" align="center">Parte VI. Archivos de configuración</th><td width="20%" align="right"> <a accesskey="n" href="smbldap-tools-smbldap_conf.html">Siguiente</a></td></tr></table><hr /></div><div class="appendix" lang="es" xml:lang="es"><div class="titlepage"><div><div><h2 class="title"><a id="phpldapadmin-template_config.php"></a>Apéndice AJ. Archivo de configuración <tt class="filename">/var/www/phpldapadmin/templates/template_config.php</tt></h2></div></div><div></div></div><table xmlns="http://www.w3.org/TR/xhtml1/transitional" border="0" bgcolor="#E0E0E0" width="90%"><tr><td><pre class="programlisting">&lt;?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/templates/template_config.php,\
// v 1.17 2004/05/08 11:14:55 xrenard Exp $

/**
 * template_config.php
 * -------------------
 * General configuration file for templates.
 * File Map:
 * 1 - Generic templates configuration
 * 2 - Samba template configuration
 * 3 - method used in template and other files
 */


/*######################################################################################
## Templates for entry creation                                                       ##
## ----------------------------                                                       ##
##                                                                                    ##
## Fill in this array with templates that you can create to suit your needs.          ##
## Each entry defines a description (to be displayed in the template list) and        ##
## a handler, which is a file that will be executed with certain POST vars set.       ##
## See the templates provided here for examples of how to make your own template.     ##
##                                                                                    ##
######################################################################################*/


$templates = array();

$templates[] =
        array(  'desc'    =&gt; 'User Account',
                'icon'    =&gt; 'images/user.png',
                'handler' =&gt; 'new_user_template.php' );
		// You can use the 'regexp' directive to restrict where
		// entries can be created for this template
                //'regexp' =&gt; '^ou=People,o=.*,c=.*$'
		'regexp' =&gt; '^ou=people,dc=.*,dc=.*$'

$templates[] =
        array(  'desc'    =&gt; 'Address Book Entry (inetOrgPerson)',
                'icon'    =&gt; 'images/user.png',
                'handler' =&gt; 'new_address_template.php' );

$templates[] =
        array(  'desc'    =&gt; 'Kolab User Entry',
                'icon'    =&gt; 'images/user.png',
                'handler' =&gt; 'new_kolab_template.php' );

$templates[] =
        array(  'desc'    =&gt; 'Organizational Unit',
                'icon'    =&gt; 'images/ou.png',
                'handler' =&gt; 'new_ou_template.php' );

$templates[] =
        array(  'desc'    =&gt; 'Posix Group',
                'icon'    =&gt; 'images/ou.png',
                'handler' =&gt; 'new_posix_group_template.php' );

$templates[] =
        array(  'desc'    =&gt; 'Samba NT Machine',
                'icon'    =&gt; 'images/nt_machine.png',
                'handler' =&gt; 'new_nt_machine.php' );
$templates[] =
        array(  'desc'    =&gt; 'Samba 3 NT Machine',
                'icon'    =&gt; 'images/nt_machine.png',
                'handler' =&gt; 'new_smb3_nt_machine.php' );
/*$templates[] =
        array(  'desc'    =&gt; 'Samba  User',
                'icon'    =&gt; 'images/nt_user.png',
                'handler' =&gt; 'new_smbuser_template.php' );
*/
$templates[] =
        array(  'desc'    =&gt; 'Samba 3 User',
                'icon'    =&gt; 'images/nt_user.png',
                'handler' =&gt; 'new_smb3_user_template.php' );
$templates[] =
        array(  'desc'    =&gt; 'Samba 3 Group Mapping',
                'icon'    =&gt; 'images/ou.png',
                'handler' =&gt; 'new_smbgroup_template.php' );

$templates[] =
        array(  'desc'    =&gt; 'DNS Entry',
                'icon'    =&gt; 'images/dc.png',
                'handler' =&gt; 'new_dns_entry.php' );

$templates[] =
	array(  'desc'    =&gt; 'Simple Security Object',
		'icon'    =&gt; 'images/user.png',
		'handler' =&gt; 'new_security_object_template.php' ); 

$templates[] =
	array(  'desc'    =&gt; 'Custom',
		'icon'    =&gt; 'images/object.png',
		'handler' =&gt; 'custom.php' ); 


/*#####################################################################################
## POSIX GROUP TEMPLATE CONFIGURATION                                                ##
## ----------------------------------                                                ##
##                                                                                   ##  
#####################################################################################*/

// uncomment to set the base dn of posix groups
// default is set to the base dn of the server
$base_posix_groups="ou=groups,dc=gsr,dc=pt";




/*######################################################################################
##  SAMBA TEMPLATE CONFIGURATION                                                      ##
##  ----------------------------                                                      ##
##                                                                                    ##
##  In order to use the samba templates, you might edit the following properties:     ##  
##  1 - $mkntpwdCommand : the path to the mkntpwd utility provided with/by Samba.     ##
##  2 - $default_samba3_domains : the domain name and the domain sid.                 ##   
##                                                                                    ##
######################################################################################*/

// path 2 the mkntpwd utility (Customize)
$mkntpwdCommand = "/usr/local/sbin/mkntpwd";

// Default domains definition (Customize)
//   (use `net getlocalsid` on samba server)
$default_samba3_domains = array();
$default_samba3_domains[] =
        array(  'name'   =&gt; 'GSRDOMAIN',
                'sid' =&gt; 'S-1-5-21-3777331929-1837441497-3139219028' );

// The base dn of samba group. (CUSTOMIZE)
$samba_base_groups = "ou=groups,dc=gsr,dc=pt";


//Definition of built-in local groups
$built_in_local_groups = array(
    "S-1-5-21-3777331929-1837441497-3139219028-512" =&gt; "Administrators",
    "S-1-5-21-3777331929-1837441497-3139219028-513" =&gt; "Users",
    "S-1-5-21-3777331929-1837441497-3139219028-514" =&gt; "Guests",
    "S-1-5-21-3777331929-1837441497-3139219028-21007" =&gt; "Power Users",
    "S-1-5-21-3777331929-1837441497-3139219028-21009" =&gt; "Account Operators",
    "S-1-5-21-3777331929-1837441497-3139219028-21011" =&gt; "Server Operators",
    "S-1-5-21-3777331929-1837441497-3139219028-21013" =&gt; "Print Operators",
    "S-1-5-21-3777331929-1837441497-3139219028-21015" =&gt; "backup Operators",
    "S-1-5-21-3777331929-1837441497-3139219028-21017" =&gt; "Replicator" );


/*######################################################################################
##  Methods used in/by templates                                                      ## 
##  ----------------------------                                                      ##
######################################################################################*/

/*
 * Returns the name of the template to use based on the DN and
 * objectClasses of an entry. If no specific modification
 * template is available, simply return 'default'. The caller
 * should append '.php' and prepend 'templates/modification/'
 * to the returned string to get the file name.
 */

function get_template( $server_id, $dn )
{
        // fetch and lowercase all the objectClasses in an array
        $object_classes = get_object_attr( $server_id, $dn, 'objectClass', true );

        if( $object_classes === null || $object_classes === false)
                return 'default';

        foreach( $object_classes as $i =&gt; $class )
                $object_classes[$i] = strtolower( $class );

        $rdn = get_rdn( $dn );
	if( in_array( 'groupofnames', $object_classes ) || 
	    in_array( 'groupofuniquenames', $object_classes ) )
	    	return 'group_of_names';
	/*
        if( in_array( 'person', $object_classes ) &amp;&amp;
            in_array( 'posixaccount', $object_classes ) )
                return 'user';
	*/
	// TODO: Write other templates and criteria therefor
	// else if ...
	//    return 'some other template';
	// else if ...
	//    return 'some other template';
	// etc.

	return 'default';
}

/**
 * Return the domains info
 *  
 */

function get_samba3_domains(){
  global $default_samba3_domains;

  // do the search for the sambadomainname object here
  // In the meantime, just return the default domains
  return $default_samba3_domains;
}


/**
 * Utily class to get the samba passwords.
 */

class MkntPasswdUtil{


  var $clearPassword = NULL;
  var $sambaPassword ;
  function MkntPasswdUtil(){
    $sambaPassword = array("sambaLMPassword" =&gt; NULL,
			   "sambaNTPassword" =&gt; NULL);
  }
  
  function createSambaPasswords($password){
    global $mkntpwdCommand;
    $this-&gt;clearPassword = $password;
    file_exists ( $mkntpwdCommand ) &amp;&amp; is_executable ( $mkntpwdCommand ) \
    or pla_error(' Unable to create the Samba passwords. Please, check \
    the configuration in template_config.php');
    $sambaPassCommand = $mkntpwdCommand . " " . $password;
    if($sambaPassCommandOutput = shell_exec($sambaPassCommand)){
      $this-&gt;sambaPassword['sambaLMPassword'] = \
      trim( substr( $sambaPassCommandOutput , 0 , \
      strPos( $sambaPassCommandOutput,':' ) ) );
      $this-&gt;sambaPassword['sambaNTPassword'] = \
      trim( substr( $sambaPassCommandOutput, \
      strPos( $sambaPassCommandOutput ,':' ) +1 ) );
      return true;
    }
    else{
      return false;
    }
  }

  function getSambaLMPassword(){
    return $this-&gt;sambaPassword['sambaLMPassword'];
  }

  function getSambaNTPassword(){
    return $this-&gt;sambaPassword['sambaNTPassword'];
  }
  
  function getSambaClearPassword(){
    return $this-&gt;clearPassword;
  }
  
  function valueOf($key){
    return  $this-&gt;sambaPassword[$key];
  }

}


/**
 * Return posix group entries
 *
 */

function get_posix_groups( $server_id , $base_dn = NULL ){
  global $servers;
  if( is_null( $base_dn ) )
    $base_dn = $servers[$server_id]['base'];  
  
  $results = pla_ldap_search( $server_id, "objectclass=posixGroup", \
             $base_dn, array() );
  if( !$results )
    return false;
  else
    return $results;
}
?&gt;</pre></td></tr></table></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="phpldapadmin-config.php.html">Anterior</a> </td><td width="20%" align="center"><a accesskey="u" href="apendice-archivos-configuracion.html">Subir</a></td><td width="40%" align="right"> <a accesskey="n" href="smbldap-tools-smbldap_conf.html">Siguiente</a></td></tr><tr><td width="40%" align="left" valign="top">Apéndice AI. Archivo de configuración /var/www/phpldapadmin/config.php </td><td width="20%" align="center"><a accesskey="h" href="index.html">Inicio</a></td><td width="40%" align="right" valign="top"> Apéndice AK. Archivo de configuración /etc/smbldap-tools/smbldap.conf</td></tr></table></div></body></html>
