2003-12-20 21:42:52 +00:00
< ? php
/*
$Id $
This code is part of LDAP Account Manager ( http :// www . sourceforge . net / projects / lam )
2006-03-03 17:30:35 +00:00
Copyright ( C ) 2003 - 2006 Tilo Lutz
2003-12-20 21:42:52 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
2005-07-21 10:33:02 +00:00
/**
* Manages Samba 2 accounts for users and hosts .
*
* @ package modules
*
* @ author Tilo Lutz
* @ author Roland Gruber
* @ author Michael Duergner
*/
/**
* Manages the object class " sambaAccount " for users and hosts.
*
* @ package modules
*/
2004-06-08 18:54:37 +00:00
class sambaAccount extends baseModule {
2004-07-03 16:12:51 +00:00
/**
* Creates a new sambaAccount object .
2004-07-05 19:41:53 +00:00
*
* @ param string $scope account type ( user , group , host )
2004-07-03 16:12:51 +00:00
*/
2007-12-28 16:08:56 +00:00
public function __construct ( $scope ) {
// List of well known rids
$this -> rids = array (
_ ( 'Domain admins' ) => 512 , _ ( 'Domain users' ) => 513 ,
_ ( 'Domain guests' ) => 514 , _ ( 'Domain computers' ) => 515 ,
_ ( 'Domain controllers' ) => 516 , _ ( 'Domain certificate admins' ) => 517 ,
_ ( 'Domain schema admins' ) => 518 , _ ( 'Domain enterprise admins' ) => 519 ,
_ ( 'Domain policy admins' ) => 520 );
// call parent constructor
parent :: __construct ( $scope );
2004-07-03 16:12:51 +00:00
}
2004-09-26 13:48:52 +00:00
/** this functin fills the error message array with messages
**/
function load_Messages () {
// error messages for input checks
$this -> messages [ 'homePath' ][ 0 ] = array ( 'ERROR' , _ ( 'Home path' ), _ ( 'Home path is invalid.' ));
2005-06-18 16:12:01 +00:00
$this -> messages [ 'homePath' ][ 1 ] = array ( 'INFO' , _ ( 'Home path' ), _ ( 'Inserted user or group name in home path.' ));
$this -> messages [ 'homePath' ][ 2 ] = array ( 'INFO' , _ ( 'Account %s:' ) . ' sambaAccount_homePath' , _ ( 'Inserted user or group name in home path.' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'profilePath' ][ 0 ] = array ( 'ERROR' , _ ( 'Profile path' ), _ ( 'Profile path is invalid!' ));
2005-06-18 16:12:01 +00:00
$this -> messages [ 'profilePath' ][ 1 ] = array ( 'INFO' , _ ( 'Profile path' ), _ ( 'Inserted user or group name in profile path.' ));
$this -> messages [ 'profilePath' ][ 2 ] = array ( 'INFO' , _ ( 'Account %s:' ) . ' sambaAccount_profilePath' , _ ( 'Inserted user or group name in profile path.' ));
2004-11-20 12:44:09 +00:00
$this -> messages [ 'logonScript' ][ 0 ] = array ( 'ERROR' , _ ( 'Logon script' ), _ ( 'Logon script is invalid!' ));
2005-06-18 16:12:01 +00:00
$this -> messages [ 'logonScript' ][ 1 ] = array ( 'INFO' , _ ( 'Logon script' ), _ ( 'Inserted user or group name in logon script.' ));
2004-11-20 12:44:09 +00:00
$this -> messages [ 'logonScript' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_logonScript' , _ ( 'Logon script is invalid!' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'workstations' ][ 0 ] = array ( 'ERROR' , _ ( 'Samba workstations' ), _ ( 'Please enter a comma separated list of host names!' ));
2004-11-20 12:44:09 +00:00
$this -> messages [ 'workstations' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_workstations' , _ ( 'Please enter a comma separated list of host names!' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'domain' ][ 0 ] = array ( 'ERROR' , _ ( 'Domain name' ), _ ( 'Domain name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.' ));
2004-11-20 12:44:09 +00:00
$this -> messages [ 'domain' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_domain' , _ ( 'Domain name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and -.' ));
2004-09-26 13:48:52 +00:00
$this -> messages [ 'lmPassword' ][ 0 ] = array ( 'ERROR' , _ ( 'Password' ), _ ( 'Please enter the same password in both password-fields.' ));
2007-05-03 19:28:12 +00:00
$this -> messages [ 'lmPassword' ][ 1 ] = array ( 'ERROR' , _ ( 'Password' ), _ ( 'Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ !' ));
$this -> messages [ 'lmPassword' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_password' , _ ( 'Password contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ !' ));
2004-11-20 12:44:09 +00:00
$this -> messages [ 'displayName' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_displayName' , _ ( 'Please enter a valid display name!' ));
2005-09-13 07:55:03 +00:00
$this -> messages [ 'displayName' ][ 1 ] = array ( 'ERROR' , _ ( 'Display name' ), _ ( 'Please enter a valid display name!' ));
2004-11-20 12:44:09 +00:00
$this -> messages [ 'pwdUnix' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_pwdUnix' , _ ( 'This value can only be \"true\" or \"false\"!' ));
$this -> messages [ 'noPassword' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_noPassword' , _ ( 'This value can only be \"true\" or \"false\"!' ));
$this -> messages [ 'noExpire' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_noExpire' , _ ( 'This value can only be \"true\" or \"false\"!' ));
$this -> messages [ 'deactivated' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_deactivated' , _ ( 'This value can only be \"true\" or \"false\"!' ));
$this -> messages [ 'pwdCanChange' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_pwdCanChange' , _ ( 'Please enter a valid date in format DD-MM-YYYY.' ));
$this -> messages [ 'pwdMustChange' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_pwdMustChange' , _ ( 'Please enter a valid date in format DD-MM-YYYY.' ));
$this -> messages [ 'homeDrive' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_homeDrive' , _ ( 'Please enter a valid drive letter.' ));
$this -> messages [ 'group' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_group' , _ ( 'Please enter a valid group RID.' ));
$this -> messages [ 'specialUser' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaAccount_specialUser' , _ ( 'Please enter a valid special user name.' ));
2006-08-14 17:24:27 +00:00
2004-09-26 13:48:52 +00:00
}
2004-06-08 18:54:37 +00:00
/**
* Returns meta data that is interpreted by parent class
*
* @ return array array with meta data
2008-02-03 14:28:28 +00:00
*
* @ see baseModule :: get_metaData ()
2004-06-08 18:54:37 +00:00
*/
function get_metaData () {
$return = array ();
2007-11-19 18:42:03 +00:00
// icon
$return [ 'icon' ] = 'samba.png' ;
2004-06-13 19:58:58 +00:00
// manages user and host accounts
$return [ " account_types " ] = array ( " user " , " host " );
2004-06-08 18:54:37 +00:00
if ( $this -> get_scope () == " host " ) {
2004-06-11 15:44:49 +00:00
// LDAP filter
$return [ " ldap_filter " ] = array ( 'and' => '(uid=*$)' , 'or' => " (objectClass=posixAccount) " );
2004-06-08 18:54:37 +00:00
}
2004-06-14 16:05:36 +00:00
// alias name
$return [ " alias " ] = _ ( 'Samba 2' );
2004-06-20 17:32:02 +00:00
// module dependencies
$return [ 'dependencies' ] = array ( 'depends' => array ( 'posixAccount' ), 'conflicts' => array ());
2006-04-05 15:48:27 +00:00
// managed object classes
$return [ 'objectClasses' ] = array ( 'sambaAccount' );
2006-05-13 08:55:31 +00:00
// managed attributes
$return [ 'attributes' ] = array ( 'rid' , 'lmPassword' , 'ntPassword' , 'pwdLastSet' , 'logonTime' , 'logoffTime' ,
'kickoffTime' , 'pwdCanChange' , 'pwdMustChange' , 'acctFlags' , 'displayName' , 'smbHome' , 'homeDrive' ,
'scriptPath' , 'profilePath' , 'userWorkstations' , 'primaryGroupID' , 'domain' );
2006-04-29 09:58:17 +00:00
// PHP extensions
2006-06-29 19:43:58 +00:00
$return [ 'extensions' ] = array ( 'mhash' , 'iconv' );
2004-07-03 16:12:51 +00:00
// profile options
if ( $this -> get_scope () == 'user' ) {
// set Unix password for Samba
$return [ 'profile_options' ][] = array (
2004-11-17 19:14:26 +00:00
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Use Unix password' ) . ': ' ),
2004-07-03 16:12:51 +00:00
1 => array ( 'kind' => 'input' , 'name' => 'sambaAccount_useunixpwd' , 'type' => 'checkbox' , 'checked' => true ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'pwdUnix' )
2004-07-03 16:12:51 +00:00
);
// set no password
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Use no password' ) . ': ' ),
1 => array ( 'kind' => 'input' , 'name' => 'sambaAccount_acctFlagsN' , 'type' => 'checkbox' , 'checked' => false ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'noPassword' )
2004-07-03 16:12:51 +00:00
);
// password expiry
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Password does not expire' ) . ': ' ),
1 => array ( 'kind' => 'input' , 'name' => 'sambaAccount_acctFlagsX' , 'type' => 'checkbox' , 'checked' => true ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'noExpire' )
2004-07-03 16:12:51 +00:00
);
// account deactivation
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Account is deactivated' ) . ': ' ),
1 => array ( 'kind' => 'input' , 'name' => 'sambaAccount_acctFlagsD' , 'type' => 'checkbox' , 'checked' => false ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'deactivated' )
2004-07-03 16:12:51 +00:00
);
// drive letter
$drives = array ();
for ( $i = 90 ; $i > 67 ; $i -- ) $drives [] = chr ( $i ) . ':' ;
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Home drive' ) . ': ' ),
1 => array ( 'kind' => 'select' , 'name' => 'sambaAccount_homeDrive' , 'options' => $drives , 'options_selected' => array ( 'Z:' )),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'homeDrive' )
2004-07-03 16:12:51 +00:00
);
// path to home directory
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Home path' ) . ': ' ),
2004-07-05 19:41:53 +00:00
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'sambaAccount_smbhome' , 'size' => '20' , 'maxlength' => '255' , 'value' => '' ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'homePath' )
2004-07-03 16:12:51 +00:00
);
// path to profile
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Profile path' ) . ': ' ),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'sambaAccount_profilePath' , 'size' => '20' , 'maxlength' => '255' , 'value' => '' ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'profilePath' )
2004-07-03 16:12:51 +00:00
);
// logon script
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Logon script' ) . ': ' ),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'sambaAccount_scriptPath' , 'size' => '20' , 'maxlength' => '255' , 'value' => '' ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'scriptPath' )
2004-07-03 16:12:51 +00:00
);
// allowed workstations
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Samba workstations' ) . ': ' ),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'sambaAccount_userWorkstations' , 'value' => '' ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'workstations' )
2004-07-03 16:12:51 +00:00
);
}
// Samba domain
$return [ 'profile_options' ][] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Domain' ) . ': ' ),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'sambaAccount_domain' , 'size' => '20' , 'maxlength' => '255' , 'value' => '' ),
2004-11-17 19:14:26 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'domain' )
2004-07-03 16:12:51 +00:00
);
// profile checks
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'sambaAccount_smbhome' ] = array ( 'type' => 'ext_preg' , 'regex' => 'UNC' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'homePath' ][ 0 ]);
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'sambaAccount_profilePath' ] = array ( 'type' => 'ext_preg' , 'regex' => 'UNC' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'profilePath' ][ 0 ]);
2005-01-22 10:50:10 +00:00
$return [ 'profile_checks' ][ 'sambaAccount_scriptPath' ] = array ( 'type' => 'ext_preg' , 'regex' => 'logonscript' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'logonScript' ][ 0 ]);
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'sambaAccount_userWorkstations' ] = array ( 'type' => 'ext_preg' , 'regex' => 'unixhost' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'workstations' ][ 0 ]);
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'sambaAccount_domain' ] = array ( 'type' => 'ext_preg' , 'regex' => 'domainname' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'domain' ][ 0 ]);
2005-01-22 10:50:10 +00:00
// profile mappings
$return [ 'profile_mappings' ] = array (
'sambaAccount_homeDrive' => 'homeDrive' ,
'sambaAccount_smbhome' => 'smbHome' ,
'sambaAccount_profilePath' => 'profilePath' ,
'sambaAccount_scriptPath' => 'scriptPath' ,
'sambaAccount_userWorkstations' => 'userWorkstations' ,
'sambaAccount_domain' => 'domain'
);
2004-08-17 15:16:17 +00:00
// available PDF fields
2004-10-30 16:46:06 +00:00
$return [ 'PDF_fields' ] = array (
'displayName' ,
'smbHome' ,
'homeDrive' ,
'scriptPath' ,
'profilePath' ,
'userWorkstations' ,
'domain' ,
'description'
);
2004-11-17 19:14:26 +00:00
// upload dependencies
$return [ 'upload_preDepends' ] = array ( 'posixAccount' , 'inetOrgPerson' );
// upload options
if ( $this -> get_scope () == " user " ) {
$return [ 'upload_columns' ] = array (
array (
'name' => 'sambaAccount_displayName' ,
'description' => _ ( 'Display name' ),
'help' => 'displayName' ,
'example' => _ ( 'Steve Miller' )
),
array (
'name' => 'sambaAccount_password' ,
'description' => _ ( 'Password' ),
'help' => 'password' ,
'example' => _ ( 'secret' )
),
array (
'name' => 'sambaAccount_pwdUnix' ,
'description' => _ ( 'Use Unix password' ),
'help' => 'pwdUnixUpload' ,
'default' => 'true' ,
'values' => 'true, false' ,
'example' => 'true'
),
array (
'name' => 'sambaAccount_noPassword' ,
'description' => _ ( 'Use no password' ),
'help' => 'noPasswordUpload' ,
'default' => 'false' ,
'values' => 'true, false' ,
'example' => 'false'
),
array (
'name' => 'sambaAccount_noExpire' ,
'description' => _ ( 'Password does not expire' ),
'help' => 'noExpireUpload' ,
'default' => 'true' ,
'values' => 'true, false' ,
'example' => 'true'
),
array (
'name' => 'sambaAccount_deactivated' ,
'description' => _ ( 'Account is deactivated' ),
'help' => 'deactivatedUpload' ,
'default' => 'false' ,
'values' => 'true, false' ,
'example' => 'false'
),
array (
'name' => 'sambaAccount_pwdCanChange' ,
'description' => _ ( 'User can change password' ),
'help' => 'pwdCanChange' ,
'default' => '31-12-2030' ,
'example' => '15-11-2006'
),
array (
'name' => 'sambaAccount_pwdMustChange' ,
'description' => _ ( 'User must change password' ),
'help' => 'pwdMustChange' ,
'default' => '31-12-2030' ,
'example' => '15-10-2006'
),
array (
'name' => 'sambaAccount_homeDrive' ,
'description' => _ ( 'Home drive' ),
'help' => 'homeDrive' ,
'example' => 'k:'
),
array (
'name' => 'sambaAccount_homePath' ,
'description' => _ ( 'Home path' ),
'help' => 'homePath' ,
2004-11-28 15:56:59 +00:00
'example' => _ ( '\\\\server\\homes\\smiller' )
2004-11-17 19:14:26 +00:00
),
array (
'name' => 'sambaAccount_profilePath' ,
'description' => _ ( 'Profile path' ),
'help' => 'profilePath' ,
2004-11-28 15:56:59 +00:00
'example' => _ ( '\\\\server\\profiles\\smiller' )
2004-11-17 19:14:26 +00:00
),
array (
2004-11-20 12:44:09 +00:00
'name' => 'sambaAccount_logonScript' ,
'description' => _ ( 'Logon script' ),
2004-11-17 19:14:26 +00:00
'help' => 'scriptPath' ,
'example' => 'logon.bat'
),
array (
'name' => 'sambaAccount_workstations' ,
'description' => _ ( 'Samba workstations' ),
2004-11-20 12:44:09 +00:00
'help' => 'workstations' ,
2004-11-17 19:14:26 +00:00
'example' => 'PC01,PC02,PC03'
),
array (
'name' => 'sambaAccount_group' ,
'description' => _ ( 'Windows group' ),
'help' => 'groupUpload' ,
2004-11-20 12:44:09 +00:00
'example' => '1235' ,
'default' => '<gidNumber>*2 + 1001'
2004-11-17 19:14:26 +00:00
),
array (
'name' => 'sambaAccount_specialUser' ,
'description' => _ ( 'Special user' ),
'help' => 'specialUser' ,
2006-10-22 07:53:33 +00:00
'example' => _ ( 'Domain admins' ),
2004-11-17 19:14:26 +00:00
'values' => implode ( " , " , array_keys ( $this -> rids ))
),
array (
'name' => 'sambaAccount_domain' ,
'description' => _ ( 'Domain' ),
'help' => 'domain' ,
'example' => _ ( 'mydomain' )
)
);
}
elseif ( $this -> get_scope () == " host " ) {
$return [ 'upload_columns' ] = array (
array (
'name' => 'sambaAccount_domain' ,
'description' => _ ( 'Domain' ),
'help' => 'domain' ,
'example' => _ ( 'mydomain' )
)
);
}
// help Entries
$return [ 'help' ] = array (
" displayName " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Display name " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " This is the account's full name on Windows systems. " )),
" password " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Samba password " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " This is the account's Windows password. " )),
2005-09-03 10:59:50 +00:00
" resetPassword " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Reset password " ),
2005-09-03 10:59:50 +00:00
" Text " => _ ( " This will reset the host's password to a default value. " )),
2004-11-17 19:14:26 +00:00
" pwdUnix " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Use Unix password " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If checked Unix password will also be used as Samba password. " )),
" pwdUnixUpload " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Use Unix password " ),
2004-11-28 19:45:10 +00:00
" Text " => _ ( " If set to \" true \" Unix password will also be used as Samba password. " )),
2004-11-17 19:14:26 +00:00
" noPassword " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Use no password " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If checked no password will be used. " )),
" noPasswordUpload " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Use no password " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If set to \" true \" no password will be used. " )),
" noExpire " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Password does not expire " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If checked password does not expire. (Setting X-Flag) " )),
" noExpireUpload " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Password does not expire " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If set to \" true \" password does not expire. (Setting X-Flag) " )),
" deactivated " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Account is deactivated " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If checked account will be deactivated. (Setting D-Flag) " )),
" deactivatedUpload " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Account is deactivated " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If set to \" true \" account will be deactivated. (Setting D-Flag) " )),
" pwdCanChange " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " User can change password " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " Date after the user is able to change his password. Format: DD-MM-YYYY " )),
2008-02-03 18:37:05 +00:00
" pwdMustChange " => array ( " Headline " => _ ( " User must change password " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " Date after the user must change his password. Format: DD-MM-YYYY " )),
" homeDrive " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Home drive " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " Drive letter assigned on windows workstations as homedirectory. " )),
" homePath " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Home path " ),
2005-06-18 16:12:01 +00:00
" Text " => _ ( 'UNC-path (\\\\server\\share) of homedirectory. $user and $group are replaced with user and group name.' ) . ' ' . _ ( " Can be left empty. " )),
2004-11-17 19:14:26 +00:00
" profilePath " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Profile path " ),
2005-06-18 16:12:01 +00:00
" Text " => _ ( 'Path of the user profile. Can be a local absolute path or a UNC-path (\\\\server\\share). $user and $group are replaced with user and group name.' ) . ' ' . _ ( " Can be left empty. " )),
2004-11-17 19:14:26 +00:00
" scriptPath " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Logon script " ),
2005-07-29 12:09:31 +00:00
" Text " => _ ( 'File name and path relative to the netlogon-share which should be executed on logon. $user and $group are replaced with user and group name.' ) . ' ' . _ ( " Can be left empty. " )),
2005-09-03 10:59:50 +00:00
" userWorkstations " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Samba workstations " ),
2005-09-03 10:59:50 +00:00
" Text " => _ ( " List of Samba workstations the user is allowed to login. Empty means every workstation. " )),
2004-11-17 19:14:26 +00:00
" workstations " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Samba workstations " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " Comma separated list of Samba workstations the user is allowed to login. Empty means every workstation. " ) . ' ' . _ ( " Can be left empty. " )),
" group " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Windows group name " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If you want to use a well known RID you can selcet a well known group. " )),
" groupUpload " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Windows group RID " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " This is the RID of the user's primary Windows group. " )),
" specialUser " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Special user " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " If you want to create domain administrators or other special users use this option. " )),
" domain " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Domain " ),
2004-11-17 19:14:26 +00:00
" Text " => _ ( " Windows domain name of account. " ) . ' ' . _ ( " Can be left empty. " ))
);
2004-06-08 18:54:37 +00:00
return $return ;
}
2005-02-16 21:00:19 +00:00
/**
* Initializes the module after it became part of an accountContainer
*
* @ param string $base the name of the accountContainer object ( $_SESSION [ $base ])
*/
2004-06-08 18:54:37 +00:00
function init ( $base ) {
2004-09-01 20:53:06 +00:00
// call parent init
parent :: init ( $base );
2006-09-03 12:41:22 +00:00
$this -> useunixpwd = true ;
2005-01-22 10:50:10 +00:00
$this -> noexpire = true ;
$this -> nopwd = false ;
$this -> deactivated = false ;
2003-12-20 21:42:52 +00:00
}
// Variables
2006-09-03 12:41:22 +00:00
/** use Unix password as samba password? */
2007-10-13 17:28:37 +00:00
private $useunixpwd ;
2005-01-22 10:50:10 +00:00
/** use no password? */
2007-10-13 17:28:37 +00:00
private $nopwd ;
2005-01-22 10:50:10 +00:00
/** password does not expire? */
2007-10-13 17:28:37 +00:00
private $noexpire ;
2005-01-22 10:50:10 +00:00
/** account deactivated? */
2007-10-13 17:28:37 +00:00
private $deactivated ;
2006-08-14 17:24:27 +00:00
2005-01-22 10:50:10 +00:00
/** Array of well known rids */
2007-10-13 17:28:37 +00:00
private $rids ;
2003-12-20 21:42:52 +00:00
2007-11-03 14:17:19 +00:00
/**
* This function is used to check if this module page can be displayed .
* It returns false if a module depends on data from other modules which was not yet entered .
*
* @ return boolean true , if page can be displayed
*/
2003-12-30 15:36:30 +00:00
function module_ready () {
2007-10-10 19:04:39 +00:00
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
if ( $attrs [ 'gidNumber' ][ 0 ] == '' ) return false ;
if ( $attrs [ 'uidNumber' ][ 0 ] == '' ) return false ;
2003-12-30 15:36:30 +00:00
return true ;
2005-09-19 18:43:10 +00:00
}
2003-12-30 15:36:30 +00:00
2005-05-10 15:34:43 +00:00
/**
* This functions returns true if all needed settings are done
*
* @ return boolean true if ready to save account
2004-02-09 18:11:01 +00:00
*/
function module_complete () {
if ( ! $this -> module_ready ()) return false ;
if ( $this -> attributes [ 'rid' ][ 0 ] == '' ) return false ;
return true ;
2006-08-14 17:24:27 +00:00
}
2004-02-09 18:11:01 +00:00
2007-11-03 14:17:19 +00:00
/**
* This function loads the LDAP attributes for this module .
*
* @ param array $attributes attribute list
2003-12-30 15:36:30 +00:00
*/
function load_attributes ( $attr ) {
2005-04-16 13:41:17 +00:00
parent :: load_attributes ( $attr );
2005-09-17 08:54:40 +00:00
if ( is_string ( $this -> attributes [ 'acctFlags' ][ 0 ])) {
if ( strpos ( $this -> attributes [ 'acctFlags' ][ 0 ], " D " )) $this -> deactivated = true ;
else $this -> deactivated = false ;
if ( strpos ( $this -> attributes [ 'acctFlags' ][ 0 ], " N " )) $this -> nopwd = true ;
else $this -> nopwd = false ;
if ( strpos ( $this -> attributes [ 'acctFlags' ][ 0 ], " X " )) $this -> noexpire = true ;
else $this -> noexpire = false ;
}
2006-05-13 08:55:31 +00:00
}
2003-12-30 15:36:30 +00:00
2007-11-03 14:17:19 +00:00
/**
* Returns a list of modifications which have to be made to the LDAP account .
*
* @ return array list of modifications
* < br > This function returns an array with 3 entries :
* < br > array ( DN1 ( 'add' => array ( $attr ), 'remove' => array ( $attr ), 'modify' => array ( $attr )), DN2 .... )
* < br > DN is the DN to change . It may be possible to change several DNs ( e . g . create a new user and add him to some groups via attribute memberUid )
* < br > " add " are attributes which have to be added to LDAP entry
* < br > " remove " are attributes which have to be removed from LDAP entry
* < br > " modify " are attributes which have to been modified in LDAP entry
2003-12-30 15:36:30 +00:00
*/
function save_attributes () {
/* Create sambaSID . Can ' t create it while loading attributes because
* it ' s psssible uidNumber has changed
*/
$special = false ;
2005-05-10 15:02:58 +00:00
if ( $this -> attributes [ 'rid' ][ 0 ] < 1000 ) $special = true ;
2007-10-10 19:04:39 +00:00
if ( ! $special ) {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$this -> attributes [ 'rid' ][ 0 ] = $attrs [ 'uidNumber' ][ 0 ] * 2 + 1000 ;
}
2005-05-10 15:02:58 +00:00
$rids = array_values ( $this -> rids );
2003-12-30 15:36:30 +00:00
$wrid = false ;
2005-05-10 15:02:58 +00:00
for ( $i = 0 ; $i < count ( $rids ); $i ++ ) {
if ( $this -> attributes [ 'primaryGroupID' ][ 0 ] == $rids [ $i ]) {
2003-12-30 15:36:30 +00:00
$wrid = true ;
2005-05-10 15:02:58 +00:00
break ;
}
}
2007-10-10 19:04:39 +00:00
if ( ! $wrid ) {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$this -> attributes [ 'primaryGroupID' ][ 0 ] = ( $attrs [ 'gidNumber' ][ 0 ] * 2 ) + 1001 ;
}
2007-10-03 18:02:10 +00:00
$return = $this -> getAccountContainer () -> save_module_attributes ( $this -> attributes , $this -> orig );
2003-12-30 15:36:30 +00:00
return $return ;
}
2005-09-07 12:58:34 +00:00
/**
* Processes user input of the primary module page .
* It checks if all input values are correct and updates the associated LDAP attributes .
*
* @ return array list of info / error messages
2003-12-20 21:42:52 +00:00
*/
2006-08-14 17:24:27 +00:00
function process_attributes () {
2006-05-17 17:45:52 +00:00
$errors = array ();
2006-08-14 17:24:27 +00:00
$this -> attributes [ 'domain' ][ 0 ] = $_POST [ 'domain' ];
2003-12-21 14:52:23 +00:00
// Start character
$flag = " [ " ;
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'acctFlagsD' ]) {
2005-01-22 10:50:10 +00:00
$flag .= " D " ;
$this -> deactivated = true ;
}
else {
$this -> deactivated = false ;
}
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'acctFlagsX' ]) {
2005-01-22 10:50:10 +00:00
$flag .= " X " ;
$this -> noexpire = true ;
}
else {
$this -> noexpire = false ;
}
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'acctFlagsN' ]) {
2005-01-22 10:50:10 +00:00
$flag .= " N " ;
$this -> nopwd = true ;
}
else {
$this -> nopwd = false ;
}
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'acctFlagsS' ]) $flag .= " S " ;
if ( $_POST [ 'acctFlagsH' ]) $flag .= " H " ;
if ( $_POST [ 'acctFlagsW' ]) $flag .= " W " ;
if ( $_POST [ 'acctFlagsU' ]) $flag .= " U " ;
2003-12-21 14:52:23 +00:00
// Expand string to fixed length
$flag = str_pad ( $flag , 12 );
// End character
$flag = $flag . " ] " ;
$this -> attributes [ 'acctFlags' ][ 0 ] = $flag ;
2005-09-13 07:55:03 +00:00
// display name
2006-08-14 17:24:27 +00:00
$this -> attributes [ 'displayName' ][ 0 ] = $_POST [ 'displayName' ];
2005-09-13 07:55:03 +00:00
if ( ! ( $this -> attributes [ 'displayName' ][ 0 ] == '' ) && ! ( get_preg ( $this -> attributes [ 'displayName' ][ 0 ], 'realname' ))) {
2006-08-16 17:42:35 +00:00
$errors [] = $this -> messages [ 'displayName' ][ 1 ];
2005-09-13 07:55:03 +00:00
}
// host attributes
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'host' ) {
2006-10-22 07:53:33 +00:00
$this -> attributes [ 'primaryGroupID' ][ 0 ] = $this -> rids [ _ ( 'Domain computers' )];
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'ResetSambaPassword' ] || ( ! $this -> attributes [ 'lmPassword' ][ 0 ])) {
2007-10-10 19:04:39 +00:00
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$hostname = $attrs [ 'uid' ][ 0 ];
2005-06-26 07:53:48 +00:00
$hostname = substr ( $hostname , 0 , strlen ( $hostname ) - 1 );
$this -> attributes [ 'lmPassword' ][ 0 ] = lmPassword ( $hostname );
$this -> attributes [ 'ntPassword' ][ 0 ] = ntPassword ( $hostname );
2005-05-10 15:34:43 +00:00
$this -> attributes [ 'pwdLastSet' ][ 0 ] = time ();
2003-12-21 14:52:23 +00:00
}
}
2005-06-26 07:53:48 +00:00
// check values for user account
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2006-08-14 17:24:27 +00:00
$this -> attributes [ 'pwdCanChange' ][ 0 ] = mktime ( intval ( $_POST [ 'pwdCanChange_h' ]), intval ( $_POST [ 'pwdCanChange_m' ]),
intval ( $_POST [ 'pwdCanChange_s' ]), intval ( $_POST [ 'pwdCanChange_mon' ]), intval ( $_POST [ 'pwdCanChange_day' ]),
intval ( $_POST [ 'pwdCanChange_yea' ]));
$this -> attributes [ 'pwdMustChange' ][ 0 ] = mktime ( intval ( $_POST [ 'pwdMustChange_h' ]), intval ( $_POST [ 'pwdMustChange_m' ]),
intval ( $_POST [ 'pwdMustChange_s' ]), intval ( $_POST [ 'pwdMustChange_mon' ]), intval ( $_POST [ 'pwdMustChange_day' ]),
intval ( $_POST [ 'pwdMustChange_yea' ]));
$this -> attributes [ 'smbHome' ][ 0 ] = $_POST [ 'smbHome' ];
$this -> attributes [ 'homeDrive' ][ 0 ] = $_POST [ 'homeDrive' ];
$this -> attributes [ 'scriptPath' ][ 0 ] = $_POST [ 'scriptPath' ];
$this -> attributes [ 'profilePath' ][ 0 ] = $_POST [ 'profilePath' ];
2004-10-16 19:51:36 +00:00
$rids = array_keys ( $this -> rids );
$wrid = false ;
for ( $i = 0 ; $i < count ( $rids ); $i ++ ) {
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'primaryGroupID' ] == $rids [ $i ]) {
2004-10-16 19:51:36 +00:00
$wrid = true ;
$this -> attributes [ 'primaryGroupID' ][ 0 ] = $this -> rids [ $rids [ $i ]];
2005-05-10 15:02:58 +00:00
break ;
2004-10-16 19:51:36 +00:00
}
2005-05-10 15:02:58 +00:00
}
2007-10-10 19:04:39 +00:00
if ( ! $wrid ) {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$this -> attributes [ 'primaryGroupID' ][ 0 ] = ( $attrs [ 'gidNumber' ][ 0 ] * 2 ) + 1001 ;
}
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'useunixpwd' ]) $this -> useunixpwd = true ;
2004-10-16 19:51:36 +00:00
else $this -> useunixpwd = false ;
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'useunixpwd' ]) {
2005-05-10 15:34:43 +00:00
$this -> useunixpwd = true ;
2007-10-13 17:28:37 +00:00
$this -> attributes [ 'lmPassword' ][ 0 ] = lmPassword ( $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getClearTextPassword ());
$this -> attributes [ 'ntPassword' ][ 0 ] = ntPassword ( $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getClearTextPassword ());
2005-05-10 15:34:43 +00:00
$this -> attributes [ 'pwdLastSet' ][ 0 ] = time ();
}
else $this -> useunixpwd = false ;
2006-08-14 17:24:27 +00:00
if ( ! $this -> useunixpwd && isset ( $_POST [ 'lmPassword' ]) && ( $_POST [ 'lmPassword' ] != '' )) {
if ( $_POST [ 'lmPassword' ] != $_POST [ 'lmPassword2' ]) {
2006-08-16 17:42:35 +00:00
$errors [] = $this -> messages [ 'lmPassword' ][ 0 ];
2006-08-14 17:24:27 +00:00
unset ( $_POST [ 'lmPassword2' ]);
2005-05-10 15:34:43 +00:00
}
2004-10-16 19:51:36 +00:00
else {
2006-08-16 17:42:35 +00:00
if ( ! get_preg ( $_POST [ 'lmPassword' ], 'password' )) $errors [] = $this -> messages [ 'lmPassword' ][ 1 ];
2005-05-10 15:34:43 +00:00
else {
2006-08-14 17:24:27 +00:00
$this -> attributes [ 'lmPassword' ][ 0 ] = lmPassword ( $_POST [ 'lmPassword' ]);
$this -> attributes [ 'ntPassword' ][ 0 ] = ntPassword ( $_POST [ 'lmPassword' ]);
2005-05-10 15:34:43 +00:00
$this -> attributes [ 'pwdLastSet' ][ 0 ] = time ();
2004-01-27 19:07:31 +00:00
}
2005-05-10 15:34:43 +00:00
}
2004-10-16 19:51:36 +00:00
}
2005-05-10 15:02:58 +00:00
// rid
$specialNames = array_keys ( $this -> rids );
2006-08-14 17:24:27 +00:00
if ( in_array ( $_POST [ 'rid' ], $specialNames )) {
$this -> attributes [ 'rid' ][ 0 ] = $this -> rids [ $_POST [ 'rid' ]];
2005-05-10 15:02:58 +00:00
}
else {
2007-10-10 19:04:39 +00:00
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$this -> attributes [ 'rid' ][ 0 ] = $attrs [ 'uidNumber' ][ 0 ] * 2 + 1000 ;
2005-05-10 15:02:58 +00:00
}
2007-10-10 19:04:39 +00:00
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$this -> attributes [ 'smbHome' ][ 0 ] = str_replace ( '$user' , $attrs [ 'uid' ][ 0 ], $this -> attributes [ 'smbHome' ][ 0 ]);
$this -> attributes [ 'smbHome' ][ 0 ] = str_replace ( '$group' , $_SESSION [ 'cache' ] -> getgrnam ( $attrs [ 'gidNumber' ][ 0 ]), $this -> attributes [ 'smbHome' ][ 0 ]);
2006-08-16 17:42:35 +00:00
if ( $this -> attributes [ 'smbHome' ][ 0 ] != $_POST [ 'smbHome' ]) $errors [] = $this -> messages [ 'homePath' ][ 1 ];
2007-10-10 19:04:39 +00:00
$this -> attributes [ 'scriptPath' ][ 0 ] = str_replace ( '$user' , $attrs [ 'uid' ][ 0 ], $this -> attributes [ 'scriptPath' ][ 0 ]);
$this -> attributes [ 'scriptPath' ][ 0 ] = str_replace ( '$group' , $_SESSION [ 'cache' ] -> getgrnam ( $attrs [ 'gidNumber' ][ 0 ]), $this -> attributes [ 'scriptPath' ][ 0 ]);
2006-08-16 17:42:35 +00:00
if ( $this -> attributes [ 'scriptPath' ][ 0 ] != $_POST [ 'scriptPath' ]) $errors [] = $this -> messages [ 'logonScript' ][ 1 ];
2007-10-10 19:04:39 +00:00
$this -> attributes [ 'profilePath' ][ 0 ] = str_replace ( '$user' , $attrs [ 'uid' ][ 0 ], $this -> attributes [ 'profilePath' ][ 0 ]);
$this -> attributes [ 'profilePath' ][ 0 ] = str_replace ( '$group' , $_SESSION [ 'cache' ] -> getgrnam ( $attrs [ 'gidNumber' ][ 0 ]), $this -> attributes [ 'profilePath' ][ 0 ]);
2006-08-16 17:42:35 +00:00
if ( $this -> attributes [ 'profiletPath' ][ 0 ] != $_POST [ 'profilePath' ]) $errors [] = $this -> messages [ 'profilePath' ][ 1 ];
2004-10-16 19:51:36 +00:00
if ( ( ! $this -> attributes [ 'smbHome' ][ 0 ] == '' ) && ( ! get_preg ( $this -> attributes [ 'smbHome' ][ 0 ], 'UNC' )))
2006-08-16 17:42:35 +00:00
$errors [] = $this -> messages [ 'homePath' ][ 0 ];
2004-10-16 19:51:36 +00:00
if ( ( ! $this -> attributes [ 'scriptPath' ][ 0 ] == '' ) && ( ! get_preg ( $this -> attributes [ 'scriptPath' ][ 0 ], 'logonscript' )))
2006-08-16 17:42:35 +00:00
$errors [] = $this -> messages [ 'logonScript' ][ 0 ];
2004-10-16 19:51:36 +00:00
if ( ( ! $this -> attributes [ 'profilePath' ][ 0 ] == '' ) && ( ! get_preg ( $this -> attributes [ 'profilePath' ][ 0 ], 'UNC' )))
2006-08-16 17:42:35 +00:00
$errors [] = $this -> messages [ 'profilePath' ][ 0 ];
2007-10-10 19:04:39 +00:00
}
2005-06-26 07:53:48 +00:00
// check values for host account
2004-10-16 19:51:36 +00:00
else {
2007-10-10 19:04:39 +00:00
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
2005-06-26 07:53:48 +00:00
if ( ! $this -> attributes [ 'rid' ][ 0 ]) {
2007-10-10 19:04:39 +00:00
$this -> attributes [ 'rid' ][ 0 ] = ( $attrs [ 'uidNumber' ][ 0 ] * 2 ) + 1000 ;
2003-12-20 21:42:52 +00:00
}
2005-06-26 07:53:48 +00:00
if ( ! $this -> attributes [ 'primaryGroupID' ][ 0 ]) {
2007-10-10 19:04:39 +00:00
$this -> attributes [ 'primaryGroupID' ][ 0 ] = ( $attrs [ 'gidNumber' ][ 0 ] * 2 ) + 1001 ;
2005-06-26 07:53:48 +00:00
}
}
2003-12-20 21:42:52 +00:00
2004-09-26 13:48:52 +00:00
if (( ! $this -> attributes [ 'domain' ][ 0 ] == '' ) && ! get_preg ( $this -> attributes [ 'domain' ][ 0 ], 'domainname' ))
2006-08-16 17:42:35 +00:00
$errors [] = $this -> messages [ 'domain' ][ 0 ];
2003-12-20 21:42:52 +00:00
2006-05-17 17:45:52 +00:00
return $errors ;
2005-09-07 12:58:34 +00:00
}
2003-12-20 21:42:52 +00:00
2005-09-07 12:58:34 +00:00
/**
* Processes user input of the workstation selection page .
* It checks if all input values are correct and updates the associated LDAP attributes .
*
* @ return array list of info / error messages
2003-12-20 21:42:52 +00:00
*/
2006-08-14 17:24:27 +00:00
function process_userWorkstations () {
2003-12-20 21:42:52 +00:00
// Load attributes
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2006-08-14 17:24:27 +00:00
if ( isset ( $_POST [ 'availableUserWorkstations' ]) && isset ( $_POST [ 'userWorkstations_add' ])) { // Add workstations to list
2005-09-01 15:20:15 +00:00
$temp = str_replace ( ' ' , '' , $this -> attributes [ 'userWorkstations' ][ 0 ]);
$workstations = explode ( ',' , $temp );
for ( $i = 0 ; $i < count ( $workstations ); $i ++ ) {
if ( $workstations [ $i ] == '' ) unset ( $workstations [ $i ]);
}
$workstations = array_values ( $workstations );
// Add new // Add workstations
2006-08-14 17:24:27 +00:00
$workstations = array_merge ( $workstations , $_POST [ 'availableUserWorkstations' ]);
2005-09-01 15:20:15 +00:00
// remove doubles
$workstations = array_flip ( $workstations );
array_unique ( $workstations );
$workstations = array_flip ( $workstations );
// sort workstations
sort ( $workstations );
// Recreate workstation string
$this -> attributes [ 'userWorkstations' ][ 0 ] = $workstations [ 0 ];
for ( $i = 1 ; $i < count ( $workstations ); $i ++ ) {
$this -> attributes [ 'userWorkstations' ][ 0 ] = $this -> attributes [ 'userWorkstations' ][ 0 ] . " , " . $workstations [ $i ];
}
}
2006-08-14 17:24:27 +00:00
elseif ( isset ( $_POST [ 'userWorkstations' ]) && isset ( $_POST [ 'userWorkstations_remove' ])) { // remove // Add workstations from list
2005-09-01 15:20:15 +00:00
// Put all workstations in array
$temp = str_replace ( ' ' , '' , $this -> attributes [ 'userWorkstations' ][ 0 ]);
$workstations = explode ( ',' , $temp );
for ( $i = 0 ; $i < count ( $workstations ); $i ++ ) {
if ( $workstations [ $i ] == '' ) unset ( $workstations [ $i ]);
}
$workstations = array_values ( $workstations );
// Remove unwanted workstations from array
2006-08-14 17:24:27 +00:00
$workstations = array_delete ( $_POST [ 'userWorkstations' ], $workstations );
2005-09-01 15:20:15 +00:00
// Recreate workstation string
$this -> attributes [ 'userWorkstations' ][ 0 ] = $workstations [ 0 ];
for ( $i = 1 ; $i < count ( $workstations ); $i ++ ) {
$this -> attributes [ 'userWorkstations' ][ 0 ] = $this -> attributes [ 'userWorkstations' ][ 0 ] . " , " . $workstations [ $i ];
}
2004-01-27 19:07:31 +00:00
}
2003-12-20 21:42:52 +00:00
}
2006-08-16 17:42:35 +00:00
return array ();
2005-09-01 15:20:15 +00:00
}
2003-12-20 21:42:52 +00:00
2007-11-03 14:17:19 +00:00
/**
* Returns the HTML meta data for the main account page .
*
* @ return array HTML meta data
*/
2006-08-14 17:24:27 +00:00
function display_html_attributes () {
2005-09-13 07:55:03 +00:00
$return [] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Display name' )),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'displayName' , 'size' => '20' , 'value' => $this -> attributes [ 'displayName' ][ 0 ]),
2 => array ( 'kind' => 'help' , 'value' => 'displayName' ));
// user attributes
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2006-02-11 13:19:27 +00:00
if ( isset ( $this -> attributes [ 'pwdCanChange' ][ 0 ])) $canchangedate = getdate ( intval ( $this -> attributes [ 'pwdCanChange' ][ 0 ]));
else $canchangedate = getdate ( 0 );
if ( isset ( $this -> attributes [ 'pwdMustChange' ][ 0 ])) $mustchangedate = getdate ( intval ( $this -> attributes [ 'pwdMustChange' ][ 0 ]));
else $mustchangedate = getdate ( 0 );
2004-01-27 19:07:31 +00:00
$return [] = array ( 0 => array ( 'kind' => 'input' , 'name' => 'pwdCanChange_h' , 'type' => 'hidden' , 'value' => $canchangedate [ 'hours' ]),
1 => array ( 'kind' => 'input' , 'name' => 'pwdCanChange_m' , 'type' => 'hidden' , 'value' => $canchangedate [ 'minutes' ]),
2 => array ( 'kind' => 'input' , 'name' => 'pwdCanChange_s' , 'type' => 'hidden' , 'value' => $canchangedate [ 'seconds' ]),
3 => array ( 'kind' => 'input' , 'name' => 'pwdMustChange_h' , 'type' => 'hidden' , 'value' => $mustchangedate [ 'hours' ]),
4 => array ( 'kind' => 'input' , 'name' => 'pwdMustChange_m' , 'type' => 'hidden' , 'value' => $mustchangedate [ 'minutes' ]),
5 => array ( 'kind' => 'input' , 'name' => 'pwdMustChange_s' , 'type' => 'hidden' , 'value' => $mustchangedate [ 'seconds' ]),
6 => array ( 'kind' => 'input' , 'name' => 'acctFlagsU' , 'type' => 'hidden' , 'value' => 'true' ));
2005-05-10 15:34:43 +00:00
$return [] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Samba password' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'lmPassword' , 'type' => 'password' , 'size' => '20' , 'maxlength' => '255' , 'value' => '' ));
$return [] = array (
0 => array ( 'kind' => 'text' , 'text' => _ ( 'Repeat password' ) ),
1 => array ( 'kind' => 'input' , 'name' => 'lmPassword2' , 'type' => 'password' , 'size' => '20' , 'maxlength' => '255' , 'value' => '' ),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'password' ));
2007-10-15 17:20:17 +00:00
if ( $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getClearTextPassword () != null ) {
2006-09-03 12:41:22 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Use Unix password' ) ),
2004-10-12 13:34:00 +00:00
1 => array ( 'kind' => 'input' , 'name' => 'useunixpwd' , 'type' => 'checkbox' , 'checked' => $this -> useunixpwd , 'value' => true ),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'pwdUnix' ));
2003-12-21 14:52:23 +00:00
}
2004-01-27 19:07:31 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Use no password' ) ),
2005-01-22 10:50:10 +00:00
1 => array ( 'kind' => 'input' , 'name' => 'acctFlagsN' , 'type' => 'checkbox' , 'checked' => $this -> nopwd ),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'noPassword' ));
2004-01-27 19:07:31 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Password does not expire' ) ),
2005-01-22 10:50:10 +00:00
1 => array ( 'kind' => 'input' , 'name' => 'acctFlagsX' , 'type' => 'checkbox' , 'checked' => $this -> noexpire ),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'noExpire' ));
2004-01-27 19:07:31 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Account is deactivated' ) ),
2005-01-22 10:50:10 +00:00
1 => array ( 'kind' => 'input' , 'name' => 'acctFlagsD' , 'type' => 'checkbox' , 'checked' => $this -> deactivated ),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'deactivated' ));
2004-01-27 19:07:31 +00:00
for ( $i = 1 ; $i <= 31 ; $i ++ ) $mday [] = $i ;
for ( $i = 1 ; $i <= 12 ; $i ++ ) $mon [] = $i ;
for ( $i = 2003 ; $i <= 2030 ; $i ++ ) $year [] = $i ;
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'User can change password' ) ),
1 => array ( 'kind' => 'table' , 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select' , 'name' => 'pwdCanChange_day' ,
'options' => $mday , 'options_selectd' => $canchangedate [ 'mday' ]),
1 => array ( 'kind' => 'select' , 'name' => 'pwdCanChange_mon' ,
'options' => $mon , 'options_selectd' => $canchangedate [ 'mon' ]),
2 => array ( 'kind' => 'select' , 'name' => 'pwdCanChange_yes' ,
'options' => $year , 'options_selectd' => $canchangedate [ 'year' ])))),
2 => array ( 'kind' => 'help' , 'value' => 'pwdCanChange' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'User must change password' ) ),
1 => array ( 'kind' => 'table' , 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'select' , 'name' => 'pwdMustChange_day' ,
'options' => $mday , 'options_selectd' => $mustchangedate [ 'mday' ]),
1 => array ( 'kind' => 'select' , 'name' => 'pwdMustChange_mon' ,
'options' => $mon , 'options_selectd' => $mustchangedate [ 'mon' ]),
2 => array ( 'kind' => 'select' , 'name' => 'pwdMustChange_yes' ,
'options' => $year , 'options_selectd' => $mustchangedate [ 'year' ])))),
2 => array ( 'kind' => 'help' , 'value' => 'pwdMustChange' ));
for ( $i = 90 ; $i > 67 ; $i -- ) $drives [] = chr ( $i ) . ':' ;
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Home drive' ) ),
1 => array ( 'kind' => 'select' , 'name' => 'homeDrive' , 'options' => $drives , 'options_selected' => array ( $this -> attributes [ 'homeDrive' ][ 0 ])),
2 => array ( 'kind' => 'help' , 'value' => 'homeDrive' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Home path' ) ),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'smbHome' , 'size' => '20' , 'maxlength' => '255' , 'value' => $this -> attributes [ 'smbHome' ][ 0 ]),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'homePath' ));
2004-01-27 19:07:31 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Profile path' ) ),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'profilePath' , 'size' => '20' , 'maxlength' => '255' , 'value' => $this -> attributes [ 'profilePath' ][ 0 ]),
2 => array ( 'kind' => 'help' , 'value' => 'profilePath' ));
2004-11-20 12:44:09 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Logon script' ) ),
2004-01-27 19:07:31 +00:00
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'scriptPath' , 'size' => '20' , 'maxlength' => '255' , 'value' => $this -> attributes [ 'scriptPath' ][ 0 ]),
2 => array ( 'kind' => 'help' , 'value' => 'scriptPath' ));
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Samba workstations' ) ),
2005-09-01 15:20:15 +00:00
1 => array ( 'kind' => 'input' , 'type' => 'submit' , 'name' => 'form_subpage_sambaAccount_userWorkstations_open' , 'value' => _ ( 'Edit workstations' )),
2004-01-27 19:07:31 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'userWorkstations' ));
2004-10-16 19:51:36 +00:00
$names = array_keys ( $this -> rids );
2005-05-10 15:02:58 +00:00
$options = array ();
$selected = array ();
$wrid = false ;
2004-10-16 19:51:36 +00:00
for ( $i = 0 ; $i < count ( $names ); $i ++ ) {
2005-05-10 15:02:58 +00:00
if ( $this -> attributes [ 'primaryGroupID' ][ 0 ] == $this -> rids [ $names [ $i ]]) {
2004-10-16 19:51:36 +00:00
$selected [] = $names [ $i ];
2003-12-21 14:52:23 +00:00
$wrid = true ;
2004-10-16 19:51:36 +00:00
}
2005-05-10 15:02:58 +00:00
else $options [] = $names [ $i ];
}
2007-10-10 19:04:39 +00:00
if ( $wrid ) {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$options [] = $_SESSION [ 'cache' ] -> getgrnam ( $attrs [ 'gidNumber' ][ 0 ]);
}
else {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$selected [] = $_SESSION [ 'cache' ] -> getgrnam ( $attrs [ 'gidNumber' ][ 0 ]);
}
2004-10-16 19:51:36 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Windows group' ) ),
1 => array ( 'kind' => 'select' , 'name' => 'primaryGroupID' , 'options' => $options , 'options_selected' => $selected ),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'group' ));
2005-05-10 15:02:58 +00:00
$options = array ();
$selected = array ();
$wrid = false ;
for ( $i = 0 ; $i < count ( $names ); $i ++ ) {
if ( $this -> attributes [ 'rid' ][ 0 ] == $this -> rids [ $names [ $i ]]) {
$selected [] = $names [ $i ];
$wrid = true ;
2004-01-27 19:07:31 +00:00
}
2005-05-10 15:02:58 +00:00
else $options [] = $names [ $i ];
}
2004-11-10 15:12:45 +00:00
if ( $wrid ) $options [] = " - " ;
2005-05-10 15:02:58 +00:00
else $selected [] = " - " ;
2004-10-16 19:51:36 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Special user' ) ),
1 => array ( 'kind' => 'select' , 'name' => 'rid' , 'options' => $options , 'options_selected' => $selected ),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'specialUser' ));
2005-09-01 15:20:15 +00:00
}
2004-10-16 19:51:36 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Domain' ) ),
1 => array ( 'kind' => 'input' , 'type' => 'text' , 'name' => 'domain' , 'size' => '20' , 'maxlength' => '255' , 'value' => $this -> attributes [ 'domain' ][ 0 ]),
2 => array ( 'kind' => 'help' , 'value' => 'domain' ));
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'host' ) {
2004-01-27 19:07:31 +00:00
$return [] = array ( 0 => array ( 'kind' => 'input' , 'name' => 'acctFlagsW' , 'type' => 'hidden' , 'value' => 'true' ));
2004-10-16 19:51:36 +00:00
$return [] = array ( 0 => array ( 'kind' => 'text' , 'text' => _ ( 'Reset password' ) ),
2006-03-04 10:49:55 +00:00
1 => array ( 'kind' => 'input' , 'type' => 'submit' , 'name' => 'ResetSambaPassword' , 'value' => _ ( 'Reset' )),
2005-09-03 10:59:50 +00:00
2 => array ( 'kind' => 'help' , 'value' => 'resetPassword' ));
2003-12-30 15:36:30 +00:00
}
2005-09-01 15:20:15 +00:00
return $return ;
}
2003-12-30 15:36:30 +00:00
2007-11-03 14:17:19 +00:00
/**
* This function will create the HTML page to edit the allowed workstations .
*
* @ return array meta HTML code
2003-12-20 21:42:52 +00:00
*/
2006-08-14 17:24:27 +00:00
function display_html_userWorkstations () {
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2004-01-27 19:07:31 +00:00
// Get list of all hosts.
2004-09-14 11:53:33 +00:00
$result = $_SESSION [ 'cache' ] -> get_cache ( 'uid' , 'sambaAccount' , 'host' );
2004-01-27 19:07:31 +00:00
if ( is_array ( $result )) {
foreach ( $result as $host ) $availableUserWorkstations [] = str_replace ( " $ " , '' , $host [ 0 ]);
sort ( $availableUserWorkstations , SORT_STRING );
$result = str_replace ( ' ' , '' , $this -> attributes [ 'userWorkstations' ][ 0 ]);
$userWorkstations = explode ( ',' , $result );
$availableUserWorkstations = array_delete ( $userWorkstations , $availableUserWorkstations );
2005-09-01 15:20:15 +00:00
}
2004-01-27 19:07:31 +00:00
$return [] = array ( 0 => array ( 'kind' => 'fieldset' , 'legend' => _ ( " Allowed workstations " ), 'value' =>
array ( 0 => array ( 0 => array ( 'kind' => 'fieldset' , 'td' => array ( 'valign' => 'top' ), 'legend' => _ ( " Allowed workstations " ), 'value' =>
2005-09-01 15:20:15 +00:00
array ( 0 => array ( 0 => array ( 'kind' => 'select' , 'name' => 'userWorkstations' , 'size' => '15' , 'multiple' => true , 'options' => $userWorkstations )))),
2004-01-27 19:07:31 +00:00
1 => array ( 'kind' => 'table' , 'value' => array ( 0 => array ( 0 => array ( 'kind' => 'input' , 'type' => 'submit' , 'name' => 'userWorkstations_add' ,
'value' => '<=' )), 1 => array ( 0 => array ( 'kind' => 'input' , 'type' => 'submit' , 'name' => 'userWorkstations_remove' , 'value' => '=>' )),
2 => array ( 0 => array ( 'kind' => 'help' , 'value' => 'userWorkstations' )))),
2 => array ( 'kind' => 'fieldset' , 'td' => array ( 'valign' => 'top' ), 'legend' => _ ( " Available workstations " ), 'value' =>
2005-09-01 15:20:15 +00:00
array ( 0 => array ( 0 => array ( 'kind' => 'select' , 'name' => 'availableUserWorkstations' , 'size' => '15' , 'multiple' => true , 'options' => $availableUserWorkstations ))))
2004-01-27 19:07:31 +00:00
))));
2005-09-01 15:20:15 +00:00
$return [] = array (
0 => array ( 'kind' => 'input' , 'type' => 'submit' , 'name' => 'form_subpage_sambaAccount_attributes_back' , 'value' => _ ( 'Back' )),
1 => array ( 'kind' => 'text' ),
2 => array ( 'kind' => 'text' ));
2003-12-20 21:42:52 +00:00
}
2005-09-01 15:20:15 +00:00
return $return ;
}
2006-08-14 17:24:27 +00:00
2005-10-09 18:05:32 +00:00
/**
* Returns the PDF entries for this module .
2006-08-14 17:24:27 +00:00
*
2005-10-09 18:05:32 +00:00
* @ return array list of possible PDF entries
*/
function get_pdfEntries () {
2007-02-13 17:51:09 +00:00
return array ( 'sambaAccount_displayName' => array ( '<block><key>' . _ ( 'Display name' ) . '</key><value>' . $this -> attributes [ 'displayName' ][ 0 ] . '</value></block>' ),
2004-05-29 19:20:28 +00:00
'sambaAccount_smbHome' => array ( '<block><key>' . _ ( 'Home path' ) . '</key><value>' . $this -> attributes [ 'smbHome' ][ 0 ] . '</value></block>' ),
'sambaAccount_homeDrive' => array ( '<block><key>' . _ ( 'Home drive' ) . '</key><value>' . $this -> attributes [ 'homePath' ][ 0 ] . '</value></block>' ),
'sambaAccount_scriptPath' => array ( '<block><key>' . _ ( 'Logon script' ) . '</key><value>' . $this -> attributes [ 'scriptPath' ][ 0 ] . '</value></block>' ),
'sambaAccount_profilePath' => array ( '<block><key>' . _ ( 'Profile path' ) . '</key><value>' . $this -> attributes [ 'profilePath' ][ 0 ] . '</value></block>' ),
'sambaAccount_userWorkstations' => array ( '<block><key>' . _ ( 'Samba workstations' ) . '</key><value>' . $this -> attributes [ 'userWorkstations' ][ 0 ] . '</value></block>' ),
'sambaAccount_domain' => array ( '<block><key>' . _ ( 'Domain' ) . '</key><value>' . $this -> attributes [ 'domain' ][ 0 ] . '</value></block>' ),
'sambaAccount_description' => array ( '<block><key>' . _ ( 'Description' ) . '</key><value>' . $this -> attributes [ 'description' ][ 0 ] . '</value></block>' ));
2004-05-24 21:39:57 +00:00
}
2004-03-14 17:33:05 +00:00
2004-11-20 12:44:09 +00:00
/**
* In this function the LDAP account is built up .
*
* @ param array $rawAccounts list of hash arrays ( name => value ) from user input
* @ param array $partialAccounts list of hash arrays ( name => value ) which are later added to LDAP
* @ param array $ids list of IDs for column position ( e . g . " posixAccount_uid " => 5 )
* @ return array list of error messages if any
*/
function build_uploadAccounts ( $rawAccounts , $ids , & $partialAccounts ) {
2006-05-17 17:45:52 +00:00
$errors = array ();
2004-11-20 12:44:09 +00:00
if ( $this -> get_scope () == 'user' ) {
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
if ( ! in_array ( " sambaAccount " , $partialAccounts [ $i ][ 'objectClass' ])) $partialAccounts [ $i ][ 'objectClass' ][] = " sambaAccount " ;
// displayName
2004-11-28 15:56:59 +00:00
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_displayName' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_displayName' ]], 'realname' )) {
$partialAccounts [ $i ][ 'displayName' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_displayName' ]];
}
else {
$errMsg = $this -> messages [ 'displayName' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-28 15:56:59 +00:00
}
2004-11-20 12:44:09 +00:00
}
// password
if ( ! get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_password' ]], 'password' )) {
$errMsg = $this -> messages [ 'lmPassword' ][ 2 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
// use Unix password
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdUnix' ]] == " " ) { // default: use Unix
2005-10-04 15:17:24 +00:00
$partialAccounts [ $i ][ 'lmPassword' ] = lmPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
$partialAccounts [ $i ][ 'ntPassword' ] = ntPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
2004-11-20 12:44:09 +00:00
}
elseif ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdUnix' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdUnix' ]] == 'true' ) { // use Unix
2005-10-04 15:17:24 +00:00
$partialAccounts [ $i ][ 'lmPassword' ] = lmPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
$partialAccounts [ $i ][ 'ntPassword' ] = ntPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
2004-11-20 12:44:09 +00:00
}
else { // use given password
$partialAccounts [ $i ][ 'lmPassword' ] = lmPassword ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_password' ]]);
$partialAccounts [ $i ][ 'ntPassword' ] = ntPassword ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_password' ]]);
}
}
else {
$errMsg = $this -> messages [ 'pwdUnix' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
// use no password
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_noPassword' ]] != " " ) {
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_noPassword' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_noPassword' ]] == 'true' ) {
$partialAccounts [ $i ][ 'lmPassword' ] = 'NO PASSWORD*****' ;
$partialAccounts [ $i ][ 'ntPassword' ] = 'NO PASSWORD*****' ;
}
}
else {
$errMsg = $this -> messages [ 'noPassword' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// account flags
$flag_expire = false ;
$flag_deactivated = false ;
// password does not expire
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_noExpire' ]] != " " ) {
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_noExpire' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_noExpire' ]] == 'false' ) {
$flag_expire = true ;
}
}
else {
$errMsg = $this -> messages [ 'noExpire' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// account is deactivated
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_deactivated' ]] != " " ) {
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_deactivated' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_deactivated' ]] == 'true' ) {
$flag_deactivated = true ;
}
}
else {
$errMsg = $this -> messages [ 'deactivated' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// set flags
$flags = " [ " ;
if ( $flag_deactivated ) $flags = $flags . " D " ;
if ( ! $flag_expire ) $flags = $flags . " X " ;
$flags = $flags . " U " ;
// Expand string to fixed length
$flags = str_pad ( $flags , 12 );
// End character
$flags = $flags . " ] " ;
$partialAccounts [ $i ][ 'acctFlags' ] = $flags ;
// passsword can be changed
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdCanChange' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdCanChange' ]], 'date' )) {
$parts = explode ( " - " , $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdCanChange' ]]);
2006-02-23 08:22:22 +00:00
$time = mktime ( 0 , 0 , 0 , intval ( $parts [ 1 ]), intval ( $parts [ 0 ]), intval ( $parts [ 2 ]));
2004-11-20 12:44:09 +00:00
$partialAccounts [ $i ][ 'pwdCanChange' ] = $time ;
}
else {
$errMsg = $this -> messages [ 'pwdCanChange' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// passsword must be changed
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdMustChange' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdMustChange' ]], 'date' )) {
$parts = explode ( " - " , $rawAccounts [ $i ][ $ids [ 'sambaAccount_pwdMustChange' ]]);
2006-02-23 08:22:22 +00:00
$time = mktime ( 0 , 0 , 0 , intval ( $parts [ 1 ]), intval ( $parts [ 0 ]), intval ( $parts [ 2 ]));
2004-11-20 12:44:09 +00:00
$partialAccounts [ $i ][ 'pwdMustChange' ] = $time ;
}
else {
$errMsg = $this -> messages [ 'pwdMustChange' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// home drive
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_homeDrive' ]] != " " ) {
if ( eregi ( " [d-z]: " , $rawAccounts [ $i ][ $ids [ 'sambaAccount_homeDrive' ]])) {
$partialAccounts [ $i ][ 'homeDrive' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_homeDrive' ]];
}
else {
$errMsg = $this -> messages [ 'homeDrive' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// home path
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_homePath' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_homePath' ]], 'UNC' )) {
$partialAccounts [ $i ][ 'smbHome' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_homePath' ]];
}
else {
2004-11-28 15:56:59 +00:00
$errMsg = $this -> messages [ 'homePath' ][ 2 ];
2004-11-20 12:44:09 +00:00
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// profile path
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_profilePath' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_profilePath' ]], 'UNC' )) {
$partialAccounts [ $i ][ 'profilePath' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_profilePath' ]];
}
else {
2004-11-28 15:56:59 +00:00
$errMsg = $this -> messages [ 'profilePath' ][ 2 ];
2004-11-20 12:44:09 +00:00
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// logon script
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_logonScript' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_logonScript' ]], 'logonscript' )) {
$partialAccounts [ $i ][ 'scriptPath' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_logonScript' ]];
}
else {
$errMsg = $this -> messages [ 'logonScript' ][ 2 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// workstations
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_workstations' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_workstations' ]], 'workstations' )) {
$partialAccounts [ $i ][ 'userWorkstations' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_workstations' ]];
}
else {
$errMsg = $this -> messages [ 'workstations' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// group
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_group' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_group' ]], 'digit' )) {
$partialAccounts [ $i ][ 'primaryGroupID' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_group' ]];
}
else {
$errMsg = $this -> messages [ 'group' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
else {
// default GID*2 + 1001
$partialAccounts [ $i ][ 'primaryGroupID' ] = $partialAccounts [ $i ][ 'gidNumber' ] * 2 + 1001 ;
}
// domain
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_domain' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_domain' ]], 'domainname' )) {
$partialAccounts [ $i ][ 'domain' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_domain' ]];
}
else {
$errMsg = $this -> messages [ 'domain' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
// special user
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_specialUser' ]] != " " ) {
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_specialUser' ]], array_keys ( $this -> rids ))) {
$partialAccounts [ $i ][ 'rid' ] = $this -> rids [ $rawAccounts [ $i ][ $ids [ 'sambaAccount_specialUser' ]]];
}
else {
$errMsg = $this -> messages [ 'specialUser' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-11-20 12:44:09 +00:00
}
}
else {
// default RID uid*2 + 1000
$partialAccounts [ $i ][ 'rid' ] = $partialAccounts [ $i ][ 'uidNumber' ] * 2 + 1000 ;
}
}
}
2004-12-09 21:40:39 +00:00
else { // hosts
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
if ( ! in_array ( " sambaAccount " , $partialAccounts [ $i ][ 'objectClass' ])) $partialAccounts [ $i ][ 'objectClass' ][] = " sambaAccount " ;
// domain
if ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_domain' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaAccount_domain' ]], 'domainname' )) {
$partialAccounts [ $i ][ 'domain' ] = $rawAccounts [ $i ][ $ids [ 'sambaAccount_domain' ]];
}
else {
$errMsg = $this -> messages [ 'domain' ][ 1 ];
array_push ( $errMsg , array ( $i ));
2006-05-17 17:45:52 +00:00
$errors [] = $errMsg ;
2004-12-09 21:40:39 +00:00
}
}
2004-12-09 22:11:23 +00:00
// RID (RID uid*2 + 1000)
$partialAccounts [ $i ][ 'rid' ] = $partialAccounts [ $i ][ 'uidNumber' ] * 2 + 1000 ;
2004-12-09 21:40:39 +00:00
// passwords ( = host name)
$partialAccounts [ $i ][ 'lmPassword' ] = lmPassword ( substr ( $partialAccounts [ $i ][ 'uid' ], 0 , sizeof ( $partialAccounts [ $i ][ 'uid' ]) - 1 ));
$partialAccounts [ $i ][ 'ntPassword' ] = ntPassword ( substr ( $partialAccounts [ $i ][ 'uid' ], 0 , sizeof ( $partialAccounts [ $i ][ 'uid' ]) - 1 ));
// flags
$partialAccounts [ $i ][ 'acctFlags' ] = " [W ] " ;
}
}
2006-05-17 17:45:52 +00:00
return $errors ;
2004-11-20 12:44:09 +00:00
}
2005-01-22 10:50:10 +00:00
/**
* Loads the values of an account profile into internal variables .
*
* @ param array $profile hash array with profile values ( identifier => value )
*/
function load_profile ( $profile ) {
// profile mappings in meta data
parent :: load_profile ( $profile );
// special profile options
// use Unix password
if ( $profile [ 'sambaAccount_useunixpwd' ][ 0 ] == " true " ) {
$this -> useunixpwd = true ;
}
elseif ( $profile [ 'sambaAccount_useunixpwd' ][ 0 ] == " false " ) {
$this -> useunixpwd = false ;
}
// use no password
if ( $profile [ 'sambaAccount_acctFlagsN' ][ 0 ] == " true " ) {
$this -> nopwd = true ;
}
elseif ( $profile [ 'sambaAccount_acctFlagsN' ][ 0 ] == " false " ) {
$this -> nopwd = false ;
}
// password expiration
if ( $profile [ 'sambaAccount_acctFlagsX' ][ 0 ] == " true " ) {
$this -> noexpire = true ;
}
elseif ( $profile [ 'sambaAccount_acctFlagsX' ][ 0 ] == " false " ) {
$this -> noexpire = false ;
}
// use no password
if ( $profile [ 'sambaAccount_acctFlagsD' ][ 0 ] == " true " ) {
$this -> deactivated = true ;
}
elseif ( $profile [ 'sambaAccount_acctFlagsD' ][ 0 ] == " false " ) {
$this -> deactivated = false ;
}
}
2006-08-14 17:24:27 +00:00
2004-03-09 12:03:39 +00:00
}
2003-12-20 21:42:52 +00:00
?>