phpldapadmin/templates/template_config.php

335 lines
12 KiB
PHP
Raw Normal View History

2009-06-30 08:10:17 +00:00
<?php
2009-06-30 09:24:29 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/templates/template_config.php,v 1.34 2005/03/05 06:27:07 wurley Exp $
2009-06-30 09:22:30 +00:00
2009-06-30 08:10:17 +00:00
/**
* General configuration file for templates.
2009-06-30 09:24:29 +00:00
*
2009-06-30 08:10:17 +00:00
* File Map:
* 1 - Generic templates configuration
* 2 - Samba template configuration
* 3 - method used in template and other files
2009-06-30 09:24:29 +00:00
*
* @package phpLDAPadmin
2009-06-30 08:10:17 +00:00
*/
/*######################################################################################
## 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[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['user_account'], // 'User Account (posixAccount)',
2009-06-30 08:10:17 +00:00
'icon' => 'images/user.png',
'handler' => 'new_user_template.php' );
2009-06-30 09:22:30 +00:00
// You can use the 'regexp' directive to restrict where
// entries can be created for this template
2009-06-30 08:10:17 +00:00
//'regexp' => '^ou=People,o=.*,c=.*$'
2009-06-30 09:22:30 +00:00
//'regexp' => '^ou=People,dc=.*,dc=.*$'
2009-06-30 08:10:17 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['address_book_inet'], // 'Address Book Entry (inetOrgPerson)',
2009-06-30 08:10:17 +00:00
'icon' => 'images/user.png',
'handler' => 'new_address_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['address_book_moz'], // 'Address Book Entry (mozillaOrgPerson)',
2009-06-30 09:22:30 +00:00
'icon' => 'images/user.png',
2009-06-30 09:24:29 +00:00
'handler' => 'new_mozillaOrgPerson_template.php' );
2009-06-30 09:22:30 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['kolab_user'], // 'Kolab User Entry',
2009-06-30 09:22:30 +00:00
'icon' => 'images/user.png',
'handler' => 'new_kolab_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['organizational_unit'], // 'Organizational Unit',
2009-06-30 08:10:17 +00:00
'icon' => 'images/ou.png',
'handler' => 'new_ou_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['organizational_role'], // 'Organizational Role',
2009-06-30 09:22:30 +00:00
'icon' => 'images/o.png',
2009-06-30 09:24:29 +00:00
'handler' => 'new_organizationalRole.php' );
2009-06-30 09:22:30 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['posix_group'], // 'Posix Group',
2009-06-30 08:10:17 +00:00
'icon' => 'images/ou.png',
'handler' => 'new_posix_group_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['samba_machine'], // 'Samba NT Machine',
2009-06-30 08:10:17 +00:00
'icon' => 'images/nt_machine.png',
'handler' => 'new_nt_machine.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['samba3_machine'], // 'Samba 3 NT Machine',
2009-06-30 08:10:17 +00:00
'icon' => 'images/nt_machine.png',
'handler' => 'new_smb3_nt_machine.php' );
2009-06-30 09:22:30 +00:00
2009-06-30 08:10:17 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['samba3_user'], // 'Samba 3 User',
2009-06-30 08:10:17 +00:00
'icon' => 'images/nt_user.png',
'handler' => 'new_smb3_user_template.php' );
2009-06-30 09:22:30 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['samba_user'], // 'Samba User',
2009-06-30 09:22:30 +00:00
'icon' => 'images/nt_user.png',
'handler' => 'new_smbuser_template.php' );
2009-06-30 08:10:17 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['samba3_group'], // 'Samba 3 Group Mapping',
2009-06-30 08:10:17 +00:00
'icon' => 'images/ou.png',
'handler' => 'new_smbgroup_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['dns_entry'], // 'DNS Entry',
2009-06-30 08:10:17 +00:00
'icon' => 'images/dc.png',
'handler' => 'new_dns_entry.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['simple_sec_object'], // 'Simple Security Object',
2009-06-30 09:22:30 +00:00
'icon' => 'images/user.png',
2009-06-30 09:24:29 +00:00
'handler' => 'new_security_object_template.php' );
2009-06-30 09:22:30 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['courier_mail_account'], // 'Courier Mail Account',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail_account.png',
2009-06-30 09:24:29 +00:00
'handler' => 'new_postfix_account_template.php' );
2009-06-30 09:22:30 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['courier_mail_alias'], // 'Courier Mail Alias',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail_alias.png',
2009-06-30 09:24:29 +00:00
'handler' => 'new_postfix_alias_template.php' );
2009-06-30 09:22:30 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['ldap_alias'], // 'LDAP Alias',
2009-06-30 09:22:30 +00:00
'icon' => 'images/go.png',
2009-06-30 09:24:29 +00:00
'handler' => 'new_alias_template.php' );
2009-06-30 09:22:30 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['sendmail_cluster'], // 'Sendmail Cluster',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail.png',
'handler' => 'new_sendmail_cluster_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['sendmail_domain'], // 'Sendmail Domain',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail.png',
'handler' => 'new_sendmail_domain_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['sendmail_alias'], // 'Sendmail Alias',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail.png',
'handler' => 'new_sendmail_alias_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['sendmail_virt_dom'], // 'Sendmail Virtual Domain',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail.png',
'handler' => 'new_sendmail_virthost_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['sendmail_virt_users'], // 'Sendmail Virtual Users',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail.png',
'handler' => 'new_sendmail_virtuser_template.php' );
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['sendmail_relays'], // 'Sendmail Relays',
2009-06-30 09:22:30 +00:00
'icon' => 'images/mail.png',
'handler' => 'new_sendmail_relay_template.php' );
2009-06-30 08:10:17 +00:00
$templates[] =
2009-06-30 09:24:29 +00:00
array( 'desc' => $lang['custom'], // 'Custom',
2009-06-30 09:22:30 +00:00
'icon' => 'images/object.png',
2009-06-30 09:24:29 +00:00
'handler' => 'custom.php' );
2009-06-30 09:22:30 +00:00
/*#####################################################################################
## POSIX GROUP TEMPLATE CONFIGURATION ##
## ---------------------------------- ##
2009-06-30 09:24:29 +00:00
## ##
2009-06-30 09:22:30 +00:00
#####################################################################################*/
// uncomment to set the base dn of posix groups
// default is set to the base dn of the server
//$base_posix_groups="ou=People,dc=example,dc=com";
2009-06-30 08:10:17 +00:00
/*######################################################################################
## SAMBA TEMPLATE CONFIGURATION ##
## ---------------------------- ##
## ##
2009-06-30 09:24:29 +00:00
## In order to use the samba templates, you might edit the following properties: ##
2009-06-30 08:10:17 +00:00
## 1 - $mkntpwdCommand : the path to the mkntpwd utility provided with/by Samba. ##
2009-06-30 09:24:29 +00:00
## 2 - $samba3_domains : the domain name and the domain sid. ##
2009-06-30 08:10:17 +00:00
## ##
######################################################################################*/
// path 2 the mkntpwd utility (Customize)
2009-06-30 09:22:30 +00:00
$mkntpwdCommand = "/usr/local/bin/mkntpwd";
2009-06-30 08:10:17 +00:00
// Default domains definition (Customize)
2009-06-30 09:24:29 +00:00
// (use `net getlocalsid` on samba server)
2009-06-30 09:22:30 +00:00
$samba3_domains = array();
$samba3_domains[] =
2009-06-30 09:24:29 +00:00
array(
'name' => $lang['samba_domain_name'], // 'My Samba domain Name',
'sid' => 'S-1-5-21-4147564533-719371898-3834029857'
);
2009-06-30 08:10:17 +00:00
2009-06-30 09:22:30 +00:00
// The base dn of samba group. (CUSTOMIZE)
//$samba_base_groups = "ou=Groups,ou=samba,dc=example,dc=org";
2009-06-30 08:10:17 +00:00
2009-06-30 09:22:30 +00:00
//Definition of built-in local groups
2009-06-30 09:24:29 +00:00
$built_in_local_groups = array(
"S-1-5-32-544" => $lang['administrators'], // Administrators
"S-1-5-32-545" => $lang['users'], // Users
"S-1-5-32-546" => $lang['guests'], // Guests
"S-1-5-32-547" => $lang['power_users'], // Power Users
"S-1-5-32-548" => $lang['account_ops'], // Account Operators
"S-1-5-32-549" => $lang['server_ops'], // Server Operators
"S-1-5-32-550" => $lang['print_ops'], // Print Operators
"S-1-5-32-551" => $lang['backup_ops'], // backup Operators
"S-1-5-32-552" => $lang['replicator'] // Replicator
);
2009-06-30 09:22:30 +00:00
2009-06-30 08:10:17 +00:00
/*######################################################################################
2009-06-30 09:24:29 +00:00
## Methods used in/by templates ##
## ---------------------------- ##
2009-06-30 08:10:17 +00:00
######################################################################################*/
2009-06-30 09:24:29 +00:00
/**
* Return the name of the template to be used based on the object being edited.
*
* 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/'
2009-06-30 08:10:17 +00:00
* to the returned string to get the file name.
2009-06-30 09:24:29 +00:00
*
* @param object $ldapserver Server Object the entry is in.
* @param dn $dn Entry we will need a template for.
2009-06-30 08:10:17 +00:00
*/
2009-06-30 09:24:29 +00:00
function get_template( $ldapserver, $dn ) {
// fetch and lowercase all the objectClasses in an array
$object_classes = get_object_attr( $ldapserver, $dn, 'objectClass', true );
if( $object_classes === null || $object_classes === false)
return 'default';
foreach( $object_classes as $i => $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 ) &&
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';
2009-06-30 08:10:17 +00:00
}
/**
* Return the domains info
2009-06-30 09:24:29 +00:00
*
2009-06-30 08:10:17 +00:00
*/
function get_samba3_domains(){
2009-06-30 09:24:29 +00:00
global $samba3_domains;
2009-06-30 09:22:30 +00:00
2009-06-30 09:24:29 +00:00
// do the search for the sambadomainname object here
// In the meantime, just return the domains defined in this config file
check_samba_setting();
return $samba3_domains;
}
2009-06-30 09:22:30 +00:00
/**
* Utily class to get the samba passwords.
2009-06-30 09:24:29 +00:00
* @package phpLDAPadmin
2009-06-30 09:22:30 +00:00
*/
class MkntPasswdUtil{
2009-06-30 09:24:29 +00:00
var $clearPassword = NULL;
var $sambaPassword ;
function MkntPasswdUtil(){
$sambaPassword = array(
"sambaLMPassword" => NULL,
"sambaNTPassword" => NULL
);
}
function createSambaPasswords($password){
global $mkntpwdCommand, $lang;
$this->clearPassword = $password;
file_exists ( $mkntpwdCommand ) && is_executable ( $mkntpwdCommand ) or pla_error( $lang['unable_smb_passwords'] );
$sambaPassCommand = $mkntpwdCommand . " " . $password;
2009-06-30 09:22:30 +00:00
2009-06-30 09:24:29 +00:00
if($sambaPassCommandOutput = shell_exec($sambaPassCommand)){
$this->sambaPassword['sambaLMPassword'] = trim( substr( $sambaPassCommandOutput , 0 , strPos( $sambaPassCommandOutput,':' ) ) );
$this->sambaPassword['sambaNTPassword'] = trim( substr( $sambaPassCommandOutput, strPos( $sambaPassCommandOutput ,':' ) +1 ) );
return true;
2009-06-30 09:22:30 +00:00
2009-06-30 09:24:29 +00:00
} else {
return false;
}
}
function getSambaLMPassword(){
return $this->sambaPassword['sambaLMPassword'];
}
function getSambaNTPassword(){
return $this->sambaPassword['sambaNTPassword'];
}
function getSambaClearPassword(){
return $this->clearPassword;
}
function valueOf($key){
return $this->sambaPassword[$key];
}
2009-06-30 09:22:30 +00:00
}
function check_samba_setting(){
2009-06-30 09:24:29 +00:00
global $samba3_domains;
// check if the samba3_domains exist and is a array
( isset($samba3_domains ) && is_array( $samba3_domains ) ) or pla_error($lang['err_smb_conf']);
// no definition for the samba domain
if(empty($samba3_domains))
pla_error($lang['err_smb_no_name_sid']);
else {
// check if there is name or a sid declared for each domains
foreach ($samba3_domains as $samba3_domain) {
isset($samba3_domain['name']) or pla_error($lang['err_smb_no_name']);
isset($samba3_domain['sid']) or pla_error($lang['err_smb_no_sid']);
}
}
2009-06-30 08:10:17 +00:00
}
?>