2003-12-20 21:42:52 +00:00
< ? php
2017-09-16 14:55:21 +00:00
2003-12-20 21:42:52 +00:00
/*
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager ( http :// www . ldap - account - manager . org / )
2006-03-03 17:30:35 +00:00
Copyright ( C ) 2003 - 2006 Tilo Lutz
2019-05-12 18:51:12 +00:00
2005 - 2019 Roland Gruber
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 3 accounts for users and hosts .
*
* @ package modules
*
* @ author Tilo Lutz
* @ author Roland Gruber
* @ author Michael Duergner
*/
2007-10-22 16:24:22 +00:00
/** terminals server options */
include_once ( 'sambaSamAccount/sambaMungedDial.inc' );
2005-07-21 10:33:02 +00:00
/**
* Manages the object class " sambaSamAccount " for users and hosts.
*
* @ package modules
*/
2009-10-08 20:16:02 +00:00
class sambaSamAccount extends baseModule implements passwordService {
2004-06-08 18:54:37 +00:00
2005-10-03 10:49:48 +00:00
// Variables
/** use no password? */
2007-10-13 17:28:37 +00:00
private $nopwd ;
2005-10-03 10:49:48 +00:00
/** password does not expire? */
2007-10-13 17:28:37 +00:00
private $noexpire ;
2005-10-03 10:49:48 +00:00
/** account deactivated? */
2007-10-13 17:28:37 +00:00
private $deactivated ;
2012-11-02 18:05:37 +00:00
/** array of well known group rids */
private $groupRids ;
/** array of well known user rids */
private $userRids ;
2005-10-03 10:49:48 +00:00
/** HEX to binary conversion table */
2007-10-13 17:28:37 +00:00
private $hex2bitstring = array ( '0' => '0000' , '1' => '0001' , '2' => '0010' , '3' => '0011' , '4' => '0100' ,
2005-10-03 10:49:48 +00:00
'5' => '0101' , '6' => '0110' , '7' => '0111' , '8' => '1000' , '9' => '1001' , 'A' => '1010' ,
'B' => '1011' , 'C' => '1100' , 'D' => '1101' , 'E' => '1110' , 'F' => '1111' );
2008-12-14 18:48:59 +00:00
/** specifies if the password should be expired */
private $expirePassword = false ;
2012-07-15 12:05:47 +00:00
/** host cache to reduce LDAP queries */
2010-11-21 14:32:42 +00:00
private $cachedHostList = null ;
2012-07-15 12:05:47 +00:00
/** group cache to reduce LDAP queries */
2010-11-21 14:32:42 +00:00
private $cachedGroupSIDList = null ;
2010-11-21 19:23:12 +00:00
/** cache for domain list */
private $cachedDomainList = null ;
2017-09-16 14:55:21 +00:00
/** delimiter for remote commands */
2013-02-27 18:56:23 +00:00
private static $SPLIT_DELIMITER = " ###x##y##x### " ;
2015-08-06 19:20:54 +00:00
2005-10-03 10:49:48 +00:00
2004-07-05 19:45:19 +00:00
/**
* Creates a new sambaSamAccount object .
*
* @ param string $scope account type ( user , group , host )
*/
2007-12-28 16:08:56 +00:00
function __construct ( $scope ) {
2012-11-02 18:05:37 +00:00
// List of well known group rids
$this -> groupRids = array (
2007-12-28 16:08:56 +00:00
_ ( '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 );
2012-11-02 18:05:37 +00:00
// List of well known user rids
$this -> userRids = array (
_ ( 'Domain admins' ) => 500 , _ ( 'Domain guests' ) => 501 , _ ( 'Domain KRBTGT' ) => 502 );
2007-12-28 16:08:56 +00:00
// call parent constructor
parent :: __construct ( $scope );
$this -> autoAddObjectClasses = false ;
2004-07-05 19:45:19 +00:00
}
2020-02-24 19:08:28 +00:00
/** this function fills the error message array with messages
2004-09-26 13:48:52 +00:00
**/
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.' ));
2004-12-01 12:59:14 +00:00
$this -> messages [ 'homePath' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_homePath' , _ ( 'Home path is invalid.' ));
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.' ));
2004-12-01 12:59:14 +00:00
$this -> messages [ 'profilePath' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_profilePath' , _ ( 'Profile path is invalid!' ));
2005-08-21 17:14:00 +00:00
$this -> messages [ 'logonScript' ][ 0 ] = array ( 'ERROR' , _ ( 'Logon script' ), _ ( 'Logon script is invalid!' ));
$this -> messages [ 'logonScript' ][ 1 ] = array ( 'INFO' , _ ( 'Logon script' ), _ ( 'Inserted user or group name in logon script.' ));
2004-12-01 12:59:14 +00:00
$this -> messages [ 'logonScript' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_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-12-01 12:59:14 +00:00
$this -> messages [ 'workstations' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_workstations' , _ ( 'Please enter a comma separated list of host names!' ));
2012-08-17 16:28:42 +00:00
$this -> messages [ 'sambaLMPassword' ][ 0 ] = array ( 'ERROR' , _ ( 'Password' ), _ ( 'Please enter the same password in both password fields.' ));
2013-01-13 10:40:47 +00:00
$this -> messages [ 'sambaLMPassword' ][ 1 ] = array ( 'ERROR' , _ ( 'Password' ), _ ( 'Password contains invalid characters. Valid characters are:' ) . ' a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ §°!' );
$this -> messages [ 'sambaLMPassword' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_password' , _ ( 'Password contains invalid characters. Valid characters are:' ) . ' a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ §°!' );
2004-12-01 12:59:14 +00:00
$this -> messages [ 'rid' ][ 2 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_rid' , _ ( 'Please enter a RID number or the name of a special account!' ));
2004-12-09 21:40:39 +00:00
$this -> messages [ 'rid' ][ 3 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_rid' , _ ( 'This is not a valid RID number!' ));
2004-12-01 12:59:14 +00:00
$this -> messages [ 'displayName' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_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!' ));
2010-09-06 17:39:19 +00:00
$this -> messages [ 'pwdUnix' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_pwdUnix' , _ ( 'This value can only be "true" or "false".' ));
$this -> messages [ 'noPassword' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_noPassword' , _ ( 'This value can only be "true" or "false".' ));
$this -> messages [ 'noExpire' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_noExpire' , _ ( 'This value can only be "true" or "false".' ));
$this -> messages [ 'deactivated' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_deactivated' , _ ( 'This value can only be "true" or "false".' ));
2005-10-01 07:26:32 +00:00
$this -> messages [ 'expireDate' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_expireDate' , _ ( 'Please enter a valid date in format DD-MM-YYYY.' ));
2004-12-01 12:59:14 +00:00
$this -> messages [ 'homeDrive' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_homeDrive' , _ ( 'Please enter a valid drive letter.' ));
$this -> messages [ 'domain' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_domain' , _ ( 'LAM was unable to find a domain with this name!' ));
2005-07-07 13:35:29 +00:00
$this -> messages [ 'logonHours' ][ 0 ] = array ( 'ERROR' , _ ( 'Logon hours' ), _ ( 'The format of the logon hours field is invalid!' ));
$this -> messages [ 'logonHours' ][ 1 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_logonHours' , _ ( 'The format of the logon hours field is invalid!' ));
2004-12-01 12:59:14 +00:00
$this -> messages [ 'group' ][ 0 ] = array ( 'ERROR' , _ ( 'Account %s:' ) . ' sambaSamAccount_group' , _ ( 'Please enter a valid group name!' ));
2008-12-15 22:27:36 +00:00
$this -> messages [ 'profileCanMustChange' ][ 0 ] = array ( 'ERROR' , _ ( 'The value for the Samba 3 field "User can/must change password" needs to be a number.' ));
2004-09-26 13:48:52 +00:00
}
2006-08-14 17:24:27 +00:00
2014-04-20 13:00:42 +00:00
/**
* Returns true if this module can manage accounts of the current type , otherwise false .
2015-08-06 19:20:54 +00:00
*
2014-04-20 13:00:42 +00:00
* @ return boolean true if module fits
*/
public function can_manage () {
return in_array ( $this -> get_scope (), array ( 'user' , 'host' ));
}
2004-06-08 18:54:37 +00:00
/**
* Returns meta data that is interpreted by parent class
*
* @ return array array with meta data
2015-08-06 19:20:54 +00:00
*
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-14 16:05:36 +00:00
// alias name
$return [ " alias " ] = _ ( 'Samba 3' );
2005-07-02 12:15:25 +00:00
// RDN attribute
$return [ " RDN " ] = array ( " sambaSID " => " low " );
2004-06-20 17:32:02 +00:00
// module dependencies
$return [ 'dependencies' ] = array ( 'depends' => array ( 'posixAccount' ), 'conflicts' => array ());
2009-10-06 17:00:43 +00:00
// LDAP filter
$return [ " ldap_filter " ] = array ( 'or' => " (objectClass=sambaSamAccount) " );
2006-04-05 15:48:27 +00:00
// managed object classes
$return [ 'objectClasses' ] = array ( 'sambaSamAccount' );
2006-05-13 08:55:31 +00:00
// managed attributes
2006-08-14 17:24:27 +00:00
$return [ 'attributes' ] = array ( 'uid' , 'sambaSID' , 'sambaLMPassword' , 'sambaNTPassword' , 'sambaPwdLastSet' ,
2010-01-19 18:16:52 +00:00
'sambaLogonTime' , 'sambaLogoffTime' , 'sambaKickoffTime' , 'sambaAcctFlags' ,
2008-12-14 18:48:59 +00:00
'sambaPwdLastSet' , 'displayName' , 'sambaHomePath' , 'sambaHomeDrive' , 'sambaLogonScript' , 'sambaProfilePath' ,
2012-08-17 16:28:42 +00:00
'sambaUserWorkstations' , 'sambaPrimaryGroupSID' , 'sambaDomainName' , 'sambaLogonHours' , 'sambaMungedDial' ,
2016-05-20 17:38:36 +00:00
'sambaPasswordHistory' , 'sambaPwdCanChange' , 'sambaPwdMustChange' ); // sambaPwdCanChange/sambaPwdMustChange only for extension removal
2006-04-29 09:58:17 +00:00
// PHP extensions
2008-08-09 11:18:36 +00:00
$return [ 'extensions' ] = array ( 'hash' , 'iconv' );
2009-12-20 14:35:42 +00:00
// profile options
2018-05-19 09:14:31 +00:00
$profileContainer = new htmlResponsiveRow ();
$profileContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_addExt' , false , _ ( 'Automatically add this extension' ), 'autoAdd' ), 12 );
2010-09-27 16:47:27 +00:00
$return [ 'profile_options' ] = $profileContainer ;
2004-07-05 19:45:19 +00:00
// profile checks
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'sambaSamAccount_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' ][ 'sambaSamAccount_profilePath' ] = array (
'type' => 'ext_preg' ,
'regex' => 'UNC' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'profilePath' ][ 0 ]);
2004-09-26 15:55:29 +00:00
$return [ 'profile_checks' ][ 'sambaSamAccount_logonScript' ] = 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' ][ 'sambaSamAccount_userWorkstations' ] = array (
'type' => 'ext_preg' ,
'regex' => 'unixhost' ,
2004-09-26 13:48:52 +00:00
'error_message' => $this -> messages [ 'workstations' ][ 0 ]);
2005-07-07 13:35:29 +00:00
$return [ 'profile_checks' ][ 'sambaSamAccount_logonHours' ] = array (
'type' => 'ext_preg' ,
'regex' => 'sambaLogonHours' ,
'error_message' => $this -> messages [ 'logonHours' ][ 0 ]);
2005-01-29 12:05:16 +00:00
// profile mappings
$return [ 'profile_mappings' ] = array (
2005-07-07 13:35:29 +00:00
'sambaSamAccount_sambaDomainName' => 'sambaDomainName' ,
2014-07-27 15:51:00 +00:00
'sambaSamAccount_displayName' => 'displayName' ,
2005-01-29 12:05:16 +00:00
);
2009-10-03 18:27:17 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomePath' )) {
$return [ 'profile_mappings' ][ 'sambaSamAccount_smbhome' ] = 'sambaHomePath' ;
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideProfilePath' )) {
$return [ 'profile_mappings' ][ 'sambaSamAccount_profilePath' ] = 'sambaProfilePath' ;
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonScript' )) {
$return [ 'profile_mappings' ][ 'sambaSamAccount_logonScript' ] = 'sambaLogonScript' ;
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideWorkstations' )) {
$return [ 'profile_mappings' ][ 'sambaSamAccount_userWorkstations' ] = 'sambaUserWorkstations' ;
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonHours' )) {
$return [ 'profile_mappings' ][ 'sambaSamAccount_logonHours' ] = 'sambaLogonHours' ;
}
2004-08-17 15:16:17 +00:00
// available PDF fields
2004-10-30 16:46:06 +00:00
$return [ 'PDF_fields' ] = array (
2010-04-05 12:38:23 +00:00
'displayName' => _ ( 'Display name' ),
2017-04-18 16:28:10 +00:00
'sambaKickoffTime' => _ ( 'Account expiration date' ),
2010-04-05 12:38:23 +00:00
'sambaDomainName' => _ ( 'Domain' ),
'sambaPrimaryGroupSID' => _ ( 'Windows group' )
2004-10-30 16:46:06 +00:00
);
2009-10-04 17:05:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomeDrive' )) {
2010-04-05 12:38:23 +00:00
$return [ 'PDF_fields' ][ 'sambaHomeDrive' ] = _ ( 'Home drive' );
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomePath' )) {
2010-04-05 12:38:23 +00:00
$return [ 'PDF_fields' ][ 'sambaHomePath' ] = _ ( 'Home path' );
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideProfilePath' )) {
2010-04-05 12:38:23 +00:00
$return [ 'PDF_fields' ][ 'sambaProfilePath' ] = _ ( 'Profile path' );
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonScript' )) {
2010-04-05 12:38:23 +00:00
$return [ 'PDF_fields' ][ 'sambaLogonScript' ] = _ ( 'Logon script' );
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideWorkstations' )) {
2010-04-05 12:38:23 +00:00
$return [ 'PDF_fields' ][ 'sambaUserWorkstations' ] = _ ( 'Samba workstations' );
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideTerminalServer' )) {
2010-04-05 12:38:23 +00:00
$return [ 'PDF_fields' ][ 'tsAllowLogin' ] = _ ( 'Allow terminal server login' );
$return [ 'PDF_fields' ][ 'tsHomeDir' ] = _ ( 'Home directory' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsHomeDrive' ] = _ ( 'Home drive' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsProfilePath' ] = _ ( 'Profile path' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsInherit' ] = _ ( 'Inherit client startup configuration' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsInitialProgram' ] = _ ( 'Initial program' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsWorkDirectory' ] = _ ( 'Working directory' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsConnectionLimit' ] = _ ( 'Connection time limit' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsDisconnectionLimit' ] = _ ( 'Disconnection time limit' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsIdleLimit' ] = _ ( 'Idle time limit' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsConnectDrives' ] = _ ( 'Connect client drives' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsConnectPrinters' ] = _ ( 'Connect client printers' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsClientPrinterDefault' ] = _ ( 'Client printer is default' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsShadowing' ] = _ ( 'Shadowing' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsBrokenConn' ] = _ ( 'On broken or timed out connection' ) . ' (TS)' ;
$return [ 'PDF_fields' ][ 'tsReconnect' ] = _ ( 'Reconnect if disconnected' ) . ' (TS)' ;
2009-10-04 17:05:51 +00:00
}
2006-10-05 17:51:17 +00:00
$return [ 'selfServiceFieldSettings' ] = array (
'syncNTPassword' => _ ( 'Sync Samba NT password with Unix password' ),
2008-12-14 10:20:05 +00:00
'syncLMPassword' => _ ( 'Sync Samba LM password with Unix password' ),
'syncSambaPwdLastSet' => _ ( 'Update attribute "sambaPwdLastSet" on password change' ),
2012-08-17 16:28:42 +00:00
'password' => _ ( 'Password' ),
2013-09-28 11:44:41 +00:00
'sambaPwdLastSet' => _ ( 'Last password change (read-only)' ),
2006-10-05 17:51:17 +00:00
);
2013-11-30 15:02:06 +00:00
// self service: fields that cannot be relabeled
$return [ 'selfServiceNoRelabelFields' ] = array ( 'syncNTPassword' , 'syncLMPassword' , 'syncSambaPwdLastSet' );
2004-11-20 12:44:56 +00:00
// help Entries
$return [ 'help' ] = array (
" displayName " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Display name " ), 'attr' => 'displayName' ,
2004-11-20 12:44:56 +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-20 12:44:56 +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-20 12:44:56 +00:00
" pwdUnix " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Use Unix password " ),
2004-11-20 12:44:56 +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-12-01 12:59:14 +00:00
" Text " => _ ( " If set to \" true \" Unix password will also be used as Samba password. " )),
2004-11-20 12:44:56 +00:00
" noPassword " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Use no password " ),
2004-11-20 12:44:56 +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-20 12:44:56 +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-20 12:44:56 +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-20 12:44:56 +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 " ),
2007-01-07 11:26:18 +00:00
" Text " => _ ( " If checked then the account will be deactivated. (Setting D-Flag) " )),
" locked " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Account is locked " ),
2007-01-07 11:26:18 +00:00
" Text " => _ ( " If checked then the account will be locked (setting L-Flag). You usually want to use this setting to unlock user accounts which were locked because of failed login attempts. " )),
2004-11-20 12:44:56 +00:00
" deactivatedUpload " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Account is deactivated " ),
2004-11-20 12:44:56 +00:00
" Text " => _ ( " If set to \" true \" account will be deactivated. (Setting D-Flag) " )),
2008-12-14 18:48:59 +00:00
" passwordIsExpired " => array (
" Headline " => _ ( " Password change at next login " ),
" Text " => _ ( " If you set this option then the user has to change his password at the next login. " )),
2004-11-20 12:44:56 +00:00
" pwdCanChange " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " User can change password " ),
2010-01-19 18:16:52 +00:00
" Text " => _ ( " Date after the user is able to change his password. " )),
2008-02-03 18:37:05 +00:00
" pwdMustChange " => array ( " Headline " => _ ( " User must change password " ),
2010-01-19 18:16:52 +00:00
" Text " => _ ( " Date after the user must change his password. " )),
2004-11-20 12:44:56 +00:00
" homeDrive " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Home drive " ), 'attr' => 'sambaHomeDrive' ,
2007-10-24 16:15:56 +00:00
" Text " => _ ( " The home directory will be connected under this drive letter. " )),
2004-11-20 12:44:56 +00:00
" homePath " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Home path " ), 'attr' => 'sambaHomePath' ,
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-20 12:44:56 +00:00
" profilePath " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Profile path " ), 'attr' => 'sambaProfilePath' ,
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-20 12:44:56 +00:00
" scriptPath " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Logon script " ), 'attr' => 'sambaLogonScript' ,
2005-06-18 16:12:01 +00:00
" Text " => _ ( 'File name and path relative to 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 (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Samba workstations " ), 'attr' => 'sambaUserWorkstations' ,
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-20 12:44:56 +00:00
" workstations " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Samba workstations " ), 'attr' => 'sambaUserWorkstations' ,
2004-11-20 12:44:56 +00:00
" Text " => _ ( " Comma separated list of Samba workstations the user is allowed to login. Empty means every workstation. " ) . ' ' . _ ( " Can be left empty. " )),
2005-09-03 10:59:50 +00:00
" group " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Windows primary group " ), 'attr' => 'sambaPrimaryGroupSID' ,
2005-09-03 10:59:50 +00:00
" Text " => _ ( " This is the user's primary Windows group. " )),
2004-11-20 12:44:56 +00:00
" groupUpload " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Windows primary group SID " ), 'attr' => 'sambaPrimaryGroupSID' ,
2004-11-20 12:44:56 +00:00
" Text " => _ ( " This is the SID of the user's primary Windows group. " )),
2005-09-03 10:59:50 +00:00
" specialUser " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Special user " ),
2005-09-03 10:59:50 +00:00
" Text " => _ ( " This allows you to define this account as a special user like administrator or guest. " )),
2004-12-01 12:59:14 +00:00
" ridUpload " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Samba RID " ),
2004-12-30 14:12:28 +00:00
" Text " => _ ( " This is the relative ID number for your Windows account. You can either enter a number or one of these special accounts: " ) .
2012-11-02 18:05:37 +00:00
implode ( " , " , array_keys ( $this -> userRids )) . " <br><br> " . _ ( " If you leave this empty LAM will use: uidNumber*2 + sambaAlgorithmicRidBase. " )),
2004-12-09 21:40:39 +00:00
" ridUploadHost " => array (
2008-02-03 18:37:05 +00:00
" Headline " => _ ( " Samba RID " ),
2004-12-09 21:40:39 +00:00
" Text " => _ ( " This is the relative ID number for your host account. If you leave this empty LAM will use: uidNumber*2 + sambaAlgorithmicRidBase. " )),
2004-11-20 12:44:56 +00:00
" domain " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Domain " ), 'attr' => 'sambaDomainName' ,
2004-12-01 12:59:14 +00:00
" Text " => _ ( " Windows domain name of account. " )),
2005-07-07 13:35:29 +00:00
" logonHours " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Logon hours " ), 'attr' => 'sambaLogonHours' ,
2005-10-13 15:36:29 +00:00
" Text " => _ ( " This option defines the allowed logon hours for this account. " )),
2004-12-01 12:59:14 +00:00
" logonHoursUpload " => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Logon hours " ), 'attr' => 'sambaLogonHours' ,
2005-10-01 07:26:32 +00:00
" Text " => _ ( " This option defines the allowed logon hours for this account. The format is the same as for the LDAP attribute. The 24*7 hours are represented as 168 bit which are saved as 21 hex (21*8 = 168) values. The first bit represents Sunday 0:00 - 0:59 in GMT. " )),
'expireDate' => array (
2012-02-04 15:56:31 +00:00
" Headline " => _ ( " Account expiration date " ), 'attr' => 'sambaKickoffTime' ,
2006-03-15 14:12:59 +00:00
" Text " => _ ( " This is the date when the account will expire. Format: DD-MM-YYYY " )),
'timeZone' => array (
" Headline " => _ ( " Time zone " ),
2007-10-22 16:24:22 +00:00
" Text " => _ ( " This is the time zone of your Samba server. LAM needs this information to display the logon hours correctly. " )),
2007-10-24 16:15:56 +00:00
'tsAllowLogin' => array (
" Headline " => _ ( " Allow terminal server login " ),
" Text " => _ ( " Activate this checkbox to allow this user to use the terminal service. " )),
'tsHomeDir' => array (
" Headline " => _ ( " Home directory " ),
" Text " => _ ( " This is the path to the user's home directory. " )),
'tsProfilePath' => array (
" Headline " => _ ( " Profile path " ),
" Text " => _ ( " Path of the user profile. " )),
'tsInherit' => array (
" Headline " => _ ( " Inherit client startup configuration " ),
" Text " => _ ( " Activate this checkbox to inherit the initial program and working directory from the client machine. " )),
'tsInitialProgram' => array (
" Headline " => _ ( " Initial program " ),
" Text " => _ ( " This program is run after the login. " )),
'tsWorkDirectory' => array (
" Headline " => _ ( " Working directory " ),
" Text " => _ ( " Working directory of initial program. " )),
'tsTimeLimit' => array (
" Headline " => _ ( " Time limit " ),
" Text " => _ ( " Please enter the time limit in minutes. 0 means unlimited. " )),
'tsConnectDrives' => array (
" Headline " => _ ( " Connect client drives " ),
" Text " => _ ( " Activate this checkbox to connect drives from the client machine. " )),
'tsConnectPrinters' => array (
" Headline " => _ ( " Connect client printers " ),
" Text " => _ ( " Activate this checkbox to connect printers from the client machine. " )),
'tsClientPrinterDefault' => array (
" Headline " => _ ( " Client printer is default " ),
" Text " => _ ( " Activate this checkbox to set the client's printer as default printer. " )),
'tsShadowing' => array (
" Headline " => _ ( " Shadowing " ),
" Text " => _ ( " Here you can specify the shadowing mode. " )),
'tsBrokenConn' => array (
" Headline " => _ ( " On broken or timed out connection " ),
" Text " => _ ( " This specifies what to do when the client connection is broken. " )),
'tsReconnect' => array (
" Headline " => _ ( " Reconnect if disconnected " ),
" Text " => _ ( " This specifies the reconnect policy. " )),
2007-10-22 16:24:22 +00:00
'terminalServer' => array (
" Headline " => _ ( " Terminal server options " ),
2008-12-15 22:27:36 +00:00
" Text " => _ ( " Here you can change the settings for the terminal server access. " )),
2009-05-03 15:16:15 +00:00
'lmHash' => array (
" Headline " => _ ( " Disable LM hashes " ),
2009-10-03 18:27:17 +00:00
" Text " => _ ( " Windows password hashes are saved by default as NT and LM hashes. LM hashes are insecure and only needed for old versions of Windows. You should disable them unless you really need them. " )),
2013-09-28 11:44:41 +00:00
'sambaPwdLastSet' => array (
" Headline " => _ ( " Last password change " ), 'attr' => 'sambaPwdLastSet' ,
" Text " => _ ( " This is the date when the user changed his password. " )),
2009-10-03 18:27:17 +00:00
'hiddenOptions' => array (
" Headline " => _ ( " Hidden options " ),
2009-12-20 14:35:42 +00:00
" Text " => _ ( " The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields. " )),
'autoAdd' => array (
" Headline " => _ ( " Automatically add this extension " ),
2016-05-26 17:41:10 +00:00
" Text " => _ ( " This will enable the extension automatically if this profile is loaded. " )),
'domainSuffix' => array (
" Headline " => _ ( " Domain suffix " ),
" Text " => _ ( " Please enter the LDAP suffix where your Samba domain entries are stored. " )),
2016-07-09 06:26:05 +00:00
'history' => array (
" Headline " => _ ( " Password history " ),
2016-07-09 07:31:55 +00:00
" Text " => _ ( " Enables password history. Depending on your LDAP server you need to select the right server-side ordering (switch ordering here if old passwords are not removed from history). " )),
2016-05-26 17:41:10 +00:00
);
2004-12-01 12:59:14 +00:00
// upload dependencies
$return [ 'upload_preDepends' ] = array ( 'posixAccount' , 'inetOrgPerson' );
// upload options
if ( $this -> get_scope () == " user " ) {
$return [ 'upload_columns' ] = array (
array (
'name' => 'sambaSamAccount_domain' ,
'description' => _ ( 'Domain' ),
'required' => true ,
'help' => 'domain' ,
'example' => _ ( 'mydomain' )
),
array (
'name' => 'sambaSamAccount_displayName' ,
'description' => _ ( 'Display name' ),
'help' => 'displayName' ,
'example' => _ ( 'Steve Miller' )
),
array (
'name' => 'sambaSamAccount_password' ,
'description' => _ ( 'Password' ),
'help' => 'password' ,
'example' => _ ( 'secret' )
),
array (
'name' => 'sambaSamAccount_pwdUnix' ,
'description' => _ ( 'Use Unix password' ),
'help' => 'pwdUnixUpload' ,
'default' => 'true' ,
'values' => 'true, false' ,
'example' => 'true'
),
array (
'name' => 'sambaSamAccount_noPassword' ,
'description' => _ ( 'Use no password' ),
'help' => 'noPasswordUpload' ,
'default' => 'false' ,
'values' => 'true, false' ,
'example' => 'false'
),
array (
'name' => 'sambaSamAccount_noExpire' ,
'description' => _ ( 'Password does not expire' ),
'help' => 'noExpireUpload' ,
'default' => 'true' ,
'values' => 'true, false' ,
'example' => 'true'
),
array (
'name' => 'sambaSamAccount_deactivated' ,
'description' => _ ( 'Account is deactivated' ),
'help' => 'deactivatedUpload' ,
'default' => 'false' ,
'values' => 'true, false' ,
'example' => 'false'
),
2005-10-01 07:26:32 +00:00
array (
'name' => 'sambaSamAccount_expireDate' ,
'description' => _ ( 'Account expiration date' ),
'help' => 'expireDate' ,
'default' => '31-12-2030' ,
2012-02-18 13:47:49 +00:00
'example' => '15-10-2020'
2005-10-01 07:26:32 +00:00
),
2004-12-01 12:59:14 +00:00
array (
2009-10-04 17:05:51 +00:00
'name' => 'sambaSamAccount_group' ,
'description' => _ ( 'Windows group' ),
'help' => 'groupUpload' ,
'example' => _ ( 'mygroup' ),
'default' => 'Domain Users'
),
array (
'name' => 'sambaSamAccount_rid' ,
'description' => _ ( 'Samba RID' ),
'help' => 'ridUpload' ,
'example' => '1235' ,
2010-12-05 13:29:53 +00:00
'default' => '{uidNumber}*2 + {sambaAlgorithmicRidBase}'
2009-10-04 17:05:51 +00:00
),
);
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomeDrive' )) {
$return [ 'upload_columns' ][] = array (
2004-12-01 12:59:14 +00:00
'name' => 'sambaSamAccount_homeDrive' ,
'description' => _ ( 'Home drive' ),
'help' => 'homeDrive' ,
'example' => 'k:'
2009-10-04 17:05:51 +00:00
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomePath' )) {
$return [ 'upload_columns' ][] = array (
2004-12-01 12:59:14 +00:00
'name' => 'sambaSamAccount_homePath' ,
'description' => _ ( 'Home path' ),
'help' => 'homePath' ,
'example' => _ ( '\\\\server\\homes\\smiller' )
2009-10-04 17:05:51 +00:00
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideProfilePath' )) {
$return [ 'upload_columns' ][] = array (
2004-12-01 12:59:14 +00:00
'name' => 'sambaSamAccount_profilePath' ,
'description' => _ ( 'Profile path' ),
'help' => 'profilePath' ,
'example' => _ ( '\\\\server\\profiles\\smiller' )
2009-10-04 17:05:51 +00:00
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonScript' )) {
$return [ 'upload_columns' ][] = array (
2004-12-01 12:59:14 +00:00
'name' => 'sambaSamAccount_logonScript' ,
'description' => _ ( 'Logon script' ),
'help' => 'scriptPath' ,
'example' => 'logon.bat'
2009-10-04 17:05:51 +00:00
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideWorkstations' )) {
$return [ 'upload_columns' ][] = array (
2004-12-01 12:59:14 +00:00
'name' => 'sambaSamAccount_workstations' ,
'description' => _ ( 'Samba workstations' ),
'help' => 'workstations' ,
'example' => 'PC01,PC02,PC03'
2009-10-04 17:05:51 +00:00
);
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonHours' )) {
$return [ 'upload_columns' ][] = array (
2004-12-01 12:59:14 +00:00
'name' => 'sambaSamAccount_logonHours' ,
'description' => _ ( 'Logon hours' ),
'help' => 'logonHoursUpload' ,
'example' => 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
2009-10-04 17:05:51 +00:00
);
}
2004-12-01 12:59:14 +00:00
}
elseif ( $this -> get_scope () == " host " ) {
$return [ 'upload_columns' ] = array (
array (
'name' => 'sambaSamAccount_domain' ,
'description' => _ ( 'Domain' ),
2004-12-09 21:40:39 +00:00
'required' => true ,
2004-12-01 12:59:14 +00:00
'help' => 'domain' ,
'example' => _ ( 'mydomain' )
),
array (
'name' => 'sambaSamAccount_rid' ,
'description' => _ ( 'Samba RID' ),
2004-12-09 21:40:39 +00:00
'help' => 'ridUploadHost' ,
2004-12-01 12:59:14 +00:00
'example' => '1235' ,
2010-12-05 13:29:53 +00:00
'default' => '{uidNumber}*2 + {sambaAlgorithmicRidBase}'
2004-12-01 12:59:14 +00:00
)
);
}
2004-06-08 18:54:37 +00:00
return $return ;
}
2005-01-29 12:05:16 +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 );
2005-01-29 12:05:16 +00:00
$this -> noexpire = true ;
$this -> nopwd = false ;
$this -> deactivated = false ;
}
2003-12-20 21:42:52 +00:00
2006-02-01 19:10:51 +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 ;
if ( $attrs [ 'uid' ][ 0 ] == '' ) return false ;
2003-12-30 15:36:30 +00:00
return true ;
2005-09-19 18:43:10 +00:00
}
2015-08-06 19:20:54 +00:00
2009-02-01 16:24:37 +00:00
/**
* This function is used to check if all settings for this module have been made .
2015-08-06 19:20:54 +00:00
*
2009-02-01 16:24:37 +00:00
* @ see baseModule :: module_complete
*
* @ return boolean true , if settings are complete
*/
public function module_complete () {
2012-04-09 13:20:24 +00:00
if ( ! $this -> isExtensionEnabled ()) {
2009-02-01 16:24:37 +00:00
return true ;
}
if ( $this -> get_scope () == " host " ) {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
if ( substr ( $attrs [ 'uid' ][ 0 ], - 1 , 1 ) != '$' ) {
2015-08-06 19:20:54 +00:00
return false ;
2009-02-01 16:24:37 +00:00
}
}
2010-06-25 14:50:13 +00:00
if ( ! isset ( $this -> attributes [ 'sambaSID' ]) || ( $this -> attributes [ 'sambaSID' ] == '' )) {
return false ;
}
2009-02-01 16:24:37 +00:00
return true ;
}
2003-12-30 15:36:30 +00:00
2007-11-03 14:17:19 +00:00
/**
* This function loads the LDAP attributes for this module .
*
2012-07-15 12:05:47 +00:00
* @ param array $attr 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 );
2007-10-05 18:09:49 +00:00
if ( isset ( $this -> attributes [ 'sambaAcctFlags' ][ 0 ])) {
2005-09-17 08:54:40 +00:00
if ( strpos ( $this -> attributes [ 'sambaAcctFlags' ][ 0 ], " D " )) $this -> deactivated = true ;
else $this -> deactivated = false ;
if ( strpos ( $this -> attributes [ 'sambaAcctFlags' ][ 0 ], " N " )) $this -> nopwd = true ;
else $this -> nopwd = false ;
if ( strpos ( $this -> attributes [ 'sambaAcctFlags' ][ 0 ], " X " )) $this -> noexpire = true ;
else $this -> noexpire = false ;
}
2008-12-14 18:48:59 +00:00
if ( isset ( $this -> attributes [ 'sambaPwdLastSet' ][ 0 ]) && ( $this -> attributes [ 'sambaPwdLastSet' ][ 0 ] === '0' )) {
$this -> expirePassword = true ;
}
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
2011-02-26 13:14:10 +00:00
* < br > " info " are values with informational value ( e . g . to be used later by pre / postModify actions )
2003-12-30 15:36:30 +00:00
*/
function save_attributes () {
2009-12-20 14:35:42 +00:00
if ( ! in_array ( 'sambaSamAccount' , $this -> attributes [ 'objectClass' ]) && ! in_array ( 'sambaSamAccount' , $this -> orig [ 'objectClass' ])) {
// skip saving if the extension was not added/modified
2007-08-25 10:08:15 +00:00
return array ();
}
2012-04-09 13:20:24 +00:00
if ( $this -> isExtensionEnabled ()) {
2009-12-20 14:35:42 +00:00
if ( $this -> expirePassword === true ) {
$this -> attributes [ 'sambaPwdLastSet' ][ 0 ] = '0' ;
}
elseif (( isset ( $this -> attributes [ 'sambaPwdLastSet' ][ 0 ])) && ( $this -> attributes [ 'sambaPwdLastSet' ][ 0 ] == '0' )) {
$this -> attributes [ 'sambaPwdLastSet' ][ 0 ] = time ();
}
2008-12-14 18:48:59 +00:00
}
2009-12-20 14:35:42 +00:00
return parent :: save_attributes ();
2005-09-03 10:59:50 +00:00
}
2003-12-20 21:42:52 +00:00
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 () {
2009-12-20 14:35:42 +00:00
// add extension
2010-10-09 14:37:15 +00:00
if ( isset ( $_POST [ 'addObjectClass' ])) {
2009-12-20 14:35:42 +00:00
$this -> attributes [ 'objectClass' ][] = 'sambaSamAccount' ;
return array ();
}
// remove extension
2010-10-09 14:37:15 +00:00
elseif ( isset ( $_POST [ 'remObjectClass' ])) {
2009-12-20 14:35:42 +00:00
$this -> attributes [ 'objectClass' ] = array_delete ( array ( 'sambaSamAccount' ), $this -> attributes [ 'objectClass' ]);
$attrKeys = array_keys ( $this -> attributes );
for ( $k = 0 ; $k < sizeof ( $attrKeys ); $k ++ ) {
if ( strpos ( $attrKeys [ $k ], 'samba' ) > - 1 ) {
unset ( $this -> attributes [ $attrKeys [ $k ]]);
}
}
if ( isset ( $this -> attributes [ 'displayName' ])) {
unset ( $this -> attributes [ 'displayName' ]);
}
return array ();
}
// skip processing if extension is not active
2012-04-09 13:20:24 +00:00
if ( ! $this -> isExtensionEnabled ()) {
2007-08-25 10:08:15 +00:00
return array ();
}
2009-05-03 15:16:15 +00:00
// delete LM hash if needed
if ( ! isset ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ]) || ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ] == 'yes' )) {
if ( isset ( $this -> attributes [ 'sambaLMPassword' ])) {
unset ( $this -> attributes [ 'sambaLMPassword' ]);
}
}
2006-05-18 08:30:22 +00:00
$errors = array ();
2010-11-21 19:23:12 +00:00
$sambaDomains = $this -> getDomains ();
2005-10-03 10:49:48 +00:00
if ( sizeof ( $sambaDomains ) == 0 ) {
2010-10-22 17:52:22 +00:00
return array ();
2005-10-03 10:49:48 +00:00
}
2009-10-04 17:05:51 +00:00
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
2014-07-27 15:51:00 +00:00
$unixGroupName = $this -> getGroupName ( $attrs [ 'gidNumber' ][ 0 ]);
2004-10-10 11:21:54 +00:00
// Save attributes
2006-08-14 17:24:27 +00:00
$this -> attributes [ 'sambaDomainName' ][ 0 ] = $_POST [ 'sambaDomainName' ];
2003-12-20 21:42:52 +00:00
// Get Domain SID from name
2008-01-15 18:50:40 +00:00
for ( $i = 0 ; $i < count ( $sambaDomains ); $i ++ ) {
2003-12-20 21:42:52 +00:00
if ( $this -> attributes [ 'sambaDomainName' ][ 0 ] == $sambaDomains [ $i ] -> name ) {
$SID = $sambaDomains [ $i ] -> SID ;
2004-10-11 12:20:27 +00:00
$RIDbase = $sambaDomains [ $i ] -> RIDbase ;
2008-01-15 18:50:40 +00:00
break ;
}
}
2003-12-20 21:42:52 +00:00
$flag = " [ " ;
2007-10-22 16:24:22 +00:00
if ( isset ( $_POST [ 'sambaAcctFlagsD' ])) {
2005-01-29 12:05:16 +00:00
$flag .= " D " ;
$this -> deactivated = true ;
}
else {
$this -> deactivated = false ;
}
2007-10-22 16:24:22 +00:00
if ( isset ( $_POST [ 'sambaAcctFlagsX' ])) {
2005-01-29 12:05:16 +00:00
$flag .= " X " ;
$this -> noexpire = true ;
}
else {
$this -> noexpire = false ;
}
2007-10-22 16:24:22 +00:00
if ( isset ( $_POST [ 'sambaAcctFlagsN' ])) {
2005-01-29 12:05:16 +00:00
$flag .= " N " ;
$this -> nopwd = true ;
}
else {
$this -> nopwd = false ;
}
2019-11-01 20:01:08 +00:00
if ( isset ( $_POST [ 'sambaAcctFlagsS' ])) {
$flag .= " S " ;
}
if ( isset ( $_POST [ 'sambaAcctFlagsH' ])) {
$flag .= " H " ;
}
if ( isset ( $_POST [ 'sambaAcctFlagsW' ])) {
$flag .= " W " ;
}
if ( isset ( $_POST [ 'sambaAcctFlagsU' ])) {
$flag .= " U " ;
}
if ( isset ( $_POST [ 'sambaAcctFlagsL' ])) {
$flag .= " L " ;
}
2003-12-20 21:42:52 +00:00
// Expand string to fixed length
$flag = str_pad ( $flag , 12 );
// End character
$flag = $flag . " ] " ;
$this -> attributes [ 'sambaAcctFlags' ][ 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' ];
2014-07-27 15:51:00 +00:00
if ( ! empty ( $this -> attributes [ 'displayName' ][ 0 ])) {
$this -> attributes [ 'displayName' ][ 0 ] = str_replace ( '$user' , $attrs [ 'uid' ][ 0 ], $this -> attributes [ 'displayName' ][ 0 ]);
$this -> attributes [ 'displayName' ][ 0 ] = str_replace ( '$group' , $unixGroupName , $this -> attributes [ 'displayName' ][ 0 ]);
}
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' ) {
2012-11-02 18:05:37 +00:00
$this -> attributes [ 'sambaPrimaryGroupSID' ][ 0 ] = $SID . " - " . $this -> groupRids [ _ ( 'Domain computers' )];
2010-06-29 17:18:50 +00:00
if ( isset ( $_POST [ 'ResetSambaPassword' ]) || ! isset ( $this -> attributes [ 'sambaNTPassword' ][ 0 ])) {
2007-10-10 19:04:39 +00:00
$hostname = $attrs [ 'uid' ][ 0 ];
2005-06-26 07:53:48 +00:00
$hostname = substr ( $hostname , 0 , strlen ( $hostname ) - 1 );
2009-05-03 15:16:15 +00:00
if ( isset ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ]) && ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ] == 'no' )) {
$this -> attributes [ 'sambaLMPassword' ][ 0 ] = lmPassword ( $hostname );
}
2005-06-26 07:53:48 +00:00
$this -> attributes [ 'sambaNTPassword' ][ 0 ] = ntPassword ( $hostname );
2005-05-08 12:39:29 +00:00
$this -> attributes [ 'sambaPwdLastSet' ][ 0 ] = time ();
2003-12-21 14:52:23 +00:00
}
2005-05-08 12:39:29 +00:00
}
2005-09-13 07:55:03 +00:00
// user attributes
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2009-10-04 17:05:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomePath' )) {
$this -> attributes [ 'sambaHomePath' ][ 0 ] = $_POST [ 'sambaHomePath' ];
$this -> attributes [ 'sambaHomePath' ][ 0 ] = str_replace ( '$user' , $attrs [ 'uid' ][ 0 ], $this -> attributes [ 'sambaHomePath' ][ 0 ]);
2009-11-26 10:59:00 +00:00
$this -> attributes [ 'sambaHomePath' ][ 0 ] = str_replace ( '$group' , $unixGroupName , $this -> attributes [ 'sambaHomePath' ][ 0 ]);
2019-11-01 20:01:08 +00:00
if ( $this -> attributes [ 'sambaHomePath' ][ 0 ] != $_POST [ 'sambaHomePath' ]) {
$errors [] = $this -> messages [ 'homePath' ][ 1 ];
}
2009-10-04 17:05:51 +00:00
if ( ( ! $this -> attributes [ 'sambaHomePath' ][ 0 ] == '' ) && ( ! get_preg ( $this -> attributes [ 'sambaHomePath' ][ 0 ], 'UNC' ))) {
$errors [] = $this -> messages [ 'homePath' ][ 0 ];
}
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomeDrive' )) {
2019-11-01 20:01:08 +00:00
if ( $_POST [ 'sambaHomeDrive' ] == " - " ) {
$this -> attributes [ 'sambaHomeDrive' ][ 0 ] = '' ;
}
else {
$this -> attributes [ 'sambaHomeDrive' ][ 0 ] = $_POST [ 'sambaHomeDrive' ];
}
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonScript' )) {
$this -> attributes [ 'sambaLogonScript' ][ 0 ] = $_POST [ 'sambaLogonScript' ];
$this -> attributes [ 'sambaLogonScript' ][ 0 ] = str_replace ( '$user' , $attrs [ 'uid' ][ 0 ], $this -> attributes [ 'sambaLogonScript' ][ 0 ]);
2009-11-26 10:59:00 +00:00
$this -> attributes [ 'sambaLogonScript' ][ 0 ] = str_replace ( '$group' , $unixGroupName , $this -> attributes [ 'sambaLogonScript' ][ 0 ]);
2019-11-01 20:01:08 +00:00
if ( $this -> attributes [ 'sambaLogonScript' ][ 0 ] != $_POST [ 'sambaLogonScript' ]) {
$errors [] = $this -> messages [ 'logonScript' ][ 1 ];
}
2009-10-04 17:05:51 +00:00
if ( ( ! $this -> attributes [ 'sambaLogonScript' ][ 0 ] == '' ) && ( ! get_preg ( $this -> attributes [ 'sambaLogonScript' ][ 0 ], 'logonscript' ))) {
$errors [] = $this -> messages [ 'logonScript' ][ 0 ];
}
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideProfilePath' )) {
$this -> attributes [ 'sambaProfilePath' ][ 0 ] = $_POST [ 'sambaProfilePath' ];
$this -> attributes [ 'sambaProfilePath' ][ 0 ] = str_replace ( '$user' , $attrs [ 'uid' ][ 0 ], $this -> attributes [ 'sambaProfilePath' ][ 0 ]);
2009-11-26 10:59:00 +00:00
$this -> attributes [ 'sambaProfilePath' ][ 0 ] = str_replace ( '$group' , $unixGroupName , $this -> attributes [ 'sambaProfilePath' ][ 0 ]);
2019-11-01 20:01:08 +00:00
if ( $this -> attributes [ 'sambaProfilePath' ][ 0 ] != $_POST [ 'sambaProfilePath' ]) {
$errors [] = $this -> messages [ 'profilePath' ][ 1 ];
}
2009-10-04 17:05:51 +00:00
if ( ! ( $this -> attributes [ 'sambaProfilePath' ][ 0 ] == '' ) &&
! ( get_preg ( $this -> attributes [ 'sambaProfilePath' ][ 0 ], 'UNC' ) xor get_preg ( $this -> attributes [ 'sambaProfilePath' ][ 0 ], 'homeDirectory' ))) {
$errors [] = $this -> messages [ 'profilePath' ][ 0 ];
}
}
2012-11-02 18:05:37 +00:00
$rids = array_keys ( $this -> groupRids );
2003-12-20 21:42:52 +00:00
$wrid = false ;
for ( $i = 0 ; $i < count ( $rids ); $i ++ ) {
2006-08-14 17:24:27 +00:00
if ( $_POST [ 'sambaPrimaryGroupSID' ] == $rids [ $i ]) {
2003-12-20 21:42:52 +00:00
$wrid = true ;
// Get Domain SID
2012-11-02 18:05:37 +00:00
$this -> attributes [ 'sambaPrimaryGroupSID' ][ 0 ] = $SID . " - " . $this -> groupRids [ $rids [ $i ]];
2003-12-20 21:42:52 +00:00
}
2010-10-09 14:37:15 +00:00
}
2005-05-08 11:04:32 +00:00
if ( ! $wrid ) {
2007-10-10 19:04:39 +00:00
$gidnumber = $attrs [ 'gidNumber' ][ 0 ];
2010-11-21 14:32:42 +00:00
$groups = $this -> getGroupSIDList ();
if ( isset ( $groups [ $gidnumber ]) && ( $groups [ $gidnumber ] != '' )) {
$this -> attributes [ 'sambaPrimaryGroupSID' ][ 0 ] = $groups [ $gidnumber ];
2005-05-08 11:04:32 +00:00
}
}
2003-12-20 21:42:52 +00:00
2012-11-02 18:05:37 +00:00
$specialRids = array_flip ( $this -> userRids );
2005-06-30 16:22:58 +00:00
// set special RID if selected
2006-08-14 17:24:27 +00:00
if ( in_array ( $_POST [ 'sambaSID' ], $specialRids )) {
2012-11-02 18:05:37 +00:00
$this -> attributes [ 'sambaSID' ][ 0 ] = $SID . '-' . $this -> userRids [ $_POST [ 'sambaSID' ]];
2005-06-30 16:22:58 +00:00
}
// standard RID
2006-08-14 17:24:27 +00:00
else if ( $_POST [ 'sambaSID' ] == " - " ) {
2005-06-30 16:22:58 +00:00
$rid = substr ( $this -> attributes [ 'sambaSID' ][ 0 ], strrpos ( $this -> attributes [ 'sambaSID' ][ 0 ], '-' ) + 1 , strlen ( $this -> attributes [ 'sambaSID' ][ 0 ]));
2008-01-15 18:50:40 +00:00
// change only if not yet set, previously set to special SID or domain changed
if ( ! isset ( $this -> attributes [ 'sambaSID' ][ 0 ])
2012-11-02 18:05:37 +00:00
|| in_array ( $rid , $this -> userRids )
2008-01-15 18:50:40 +00:00
|| ( strpos ( $this -> attributes [ 'sambaSID' ][ 0 ], $SID ) === false )) {
2007-10-10 19:04:39 +00:00
$this -> attributes [ 'sambaSID' ][ 0 ] = $SID . " - " . (( $attrs [ 'uidNumber' ][ 0 ] * 2 ) + $RIDbase );
2003-12-21 14:52:23 +00:00
}
2004-10-16 19:51:36 +00:00
}
2005-06-26 07:53:48 +00:00
}
else { // host
2010-06-29 17:18:50 +00:00
if ( ! isset ( $this -> attributes [ 'sambaSID' ][ 0 ])) {
2007-10-10 19:04:39 +00:00
$this -> attributes [ 'sambaSID' ][ 0 ] = $SID . " - " . (( $attrs [ 'uidNumber' ][ 0 ] * 2 ) + $RIDbase );
2003-12-20 21:42:52 +00:00
}
2005-06-26 07:53:48 +00:00
}
2012-01-15 19:34:14 +00:00
if ( isset ( $_POST [ 'forcePasswordChangeOption' ])) {
2008-12-14 18:48:59 +00:00
$this -> expirePassword = true ;
}
else {
$this -> expirePassword = false ;
}
2006-05-18 08:30:22 +00:00
return $errors ;
2005-09-01 15:20:15 +00:00
}
2003-12-20 21:42:52 +00:00
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_sambaUserWorkstations () {
2003-12-20 21:42:52 +00:00
// Load attributes
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2019-11-01 19:58:22 +00:00
if ( isset ( $_POST [ 'workstations_2' ]) && isset ( $_POST [ 'workstations_left' ])) { // Add workstations to list
2010-09-28 18:36:22 +00:00
$workstations = array ();
if ( isset ( $this -> attributes [ 'sambaUserWorkstations' ][ 0 ])) {
$temp = str_replace ( ' ' , '' , $this -> attributes [ 'sambaUserWorkstations' ][ 0 ]);
$workstations = explode ( ',' , $temp );
for ( $i = 0 ; $i < count ( $workstations ); $i ++ ) {
2019-11-01 19:58:22 +00:00
if ( $workstations [ $i ] == '' ) {
unset ( $workstations [ $i ]);
}
2010-09-28 18:36:22 +00:00
}
$workstations = array_values ( $workstations );
2005-09-07 12:58:34 +00:00
}
// Add new // Add workstations
2019-11-01 19:58:22 +00:00
$workstations = array_merge ( $workstations , $_POST [ 'workstations_2' ]);
2005-09-07 12:58:34 +00:00
// remove doubles
$workstations = array_flip ( $workstations );
2018-12-23 09:32:36 +00:00
$workstations = array_unique ( $workstations );
2005-09-07 12:58:34 +00:00
$workstations = array_flip ( $workstations );
// sort workstations
sort ( $workstations );
// Recreate workstation string
$this -> attributes [ 'sambaUserWorkstations' ][ 0 ] = $workstations [ 0 ];
for ( $i = 1 ; $i < count ( $workstations ); $i ++ ) {
$this -> attributes [ 'sambaUserWorkstations' ][ 0 ] = $this -> attributes [ 'sambaUserWorkstations' ][ 0 ] . " , " . $workstations [ $i ];
2003-12-20 21:42:52 +00:00
}
2005-09-07 12:58:34 +00:00
}
2019-11-01 19:58:22 +00:00
elseif ( isset ( $_POST [ 'workstations_1' ]) && isset ( $_POST [ 'workstations_right' ])) { // remove // Add workstations from list
2005-09-07 12:58:34 +00:00
// Put all workstations in array
$temp = str_replace ( ' ' , '' , $this -> attributes [ 'sambaUserWorkstations' ][ 0 ]);
$workstations = explode ( ',' , $temp );
for ( $i = 0 ; $i < count ( $workstations ); $i ++ ) {
2019-11-01 19:58:22 +00:00
if ( $workstations [ $i ] == '' ) {
unset ( $workstations [ $i ]);
}
2005-09-07 12:58:34 +00:00
}
$workstations = array_values ( $workstations );
// Remove unwanted workstations from array
2019-11-01 19:58:22 +00:00
$workstations = array_delete ( $_POST [ 'workstations_1' ], $workstations );
2005-09-07 12:58:34 +00:00
// Recreate workstation string
2010-09-28 18:36:22 +00:00
unset ( $this -> attributes [ 'sambaUserWorkstations' ][ 0 ]);
if ( sizeof ( $workstations ) > 0 ) {
$this -> attributes [ 'sambaUserWorkstations' ][ 0 ] = $workstations [ 0 ];
for ( $i = 1 ; $i < count ( $workstations ); $i ++ ) {
$this -> attributes [ 'sambaUserWorkstations' ][ 0 ] = $this -> attributes [ 'sambaUserWorkstations' ][ 0 ] . " , " . $workstations [ $i ];
}
2005-09-07 12:58:34 +00:00
}
2004-01-27 19:07:31 +00:00
}
2005-09-07 12:58:34 +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
2005-07-07 13:35:29 +00:00
/**
2005-09-07 12:58:34 +00:00
* Processes user input of the logon hours page .
* It checks if all input values are correct and updates the associated LDAP attributes .
2005-07-07 13:35:29 +00:00
*
2005-09-07 12:58:34 +00:00
* @ return array list of info / error messages
2005-07-07 13:35:29 +00:00
*/
2006-08-14 17:24:27 +00:00
function process_logonHours () {
2019-11-01 20:01:08 +00:00
if ( isset ( $_POST [ 'form_subpage_sambaSamAccount_attributes_abort' ])) {
return array ();
}
2005-07-07 13:35:29 +00:00
// set new logon hours
$logonHours = '' ;
2005-10-09 10:32:21 +00:00
for ( $i = 0 ; $i < 24 * 7 ; $i ++ ) {
2006-08-14 17:24:27 +00:00
$logonHours .= isset ( $_POST [ 'lh_' . $i ]) ? '1' : '0' ;
2005-07-07 13:35:29 +00:00
}
// reconstruct HEX string
$bitstring2hex = array_flip ( $this -> hex2bitstring );
$logonHoursNew = '' ;
2005-10-09 10:32:21 +00:00
for ( $i = 0 ; $i < 21 ; $i ++ ) {
$part = strrev ( substr ( $logonHours , $i * 8 , 8 ));
2015-06-08 18:33:38 +00:00
$byte [ 'hi' ] = substr ( $part , 0 , 4 );
$byte [ 'low' ] = substr ( $part , 4 , 4 );
$hex = $bitstring2hex [ $byte [ 'hi' ]] . $bitstring2hex [ $byte [ 'low' ]];
2005-07-07 13:35:29 +00:00
$logonHoursNew = $logonHoursNew . $hex ;
}
$this -> attributes [ 'sambaLogonHours' ][ 0 ] = $logonHoursNew ;
2006-08-16 17:42:35 +00:00
return array ();
2005-07-07 13:35:29 +00:00
}
2006-08-14 17:24:27 +00:00
2006-11-11 10:02:13 +00:00
/**
* Processes user input of the time selection page .
*
* @ return array list of info / error messages
*/
function process_time () {
$return = array ();
// find button name
$buttonName = '' ;
$postKeys = array_keys ( $_POST );
for ( $i = 0 ; $i < sizeof ( $postKeys ); $i ++ ) {
if ( strpos ( $postKeys [ $i ], 'form_subpage_sambaSamAccount_attributes_' ) !== false ) {
$buttonName = $postKeys [ $i ];
}
}
2019-11-01 20:01:08 +00:00
if (( $buttonName == '' ) || ( strpos ( $buttonName , '_back' ) !== false )) {
return array ();
}
2006-11-11 10:02:13 +00:00
// get attribute name
$attr = '' ;
2010-01-19 18:16:52 +00:00
if ( strpos ( $buttonName , 'sambaKickoffTime' ) !== false ) {
2006-11-11 10:02:13 +00:00
$attr = 'sambaKickoffTime' ;
}
2019-11-01 20:01:08 +00:00
if ( $attr == '' ) {
return array ();
}
2006-11-11 10:02:13 +00:00
// determine action
if ( strpos ( $buttonName , '_change' ) !== false ) {
// set new time
2011-02-24 19:30:00 +00:00
$this -> setExpirationDate ( $_POST [ 'expire_yea' ], $_POST [ 'expire_mon' ], $_POST [ 'expire_day' ]);
2012-02-18 13:47:49 +00:00
// sync other modules
2011-02-24 19:30:00 +00:00
if ( isset ( $_POST [ 'syncShadow' ]) && ( $_POST [ 'syncShadow' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'shadowAccount' ) -> setExpirationDate (
$_POST [ 'expire_yea' ], $_POST [ 'expire_mon' ], $_POST [ 'expire_day' ]);
}
2012-02-18 13:47:49 +00:00
if ( isset ( $_POST [ 'syncHeimdal' ]) && ( $_POST [ 'syncHeimdal' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'heimdalKerberos' ) -> setExpirationDate (
$_POST [ 'expire_yea' ], $_POST [ 'expire_mon' ], $_POST [ 'expire_day' ]);
}
2012-11-11 11:35:45 +00:00
if ( isset ( $_POST [ 'syncMIT' ]) && ( $_POST [ 'syncMIT' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'mitKerberos' ) -> setExpirationDate (
$_POST [ 'expire_yea' ], $_POST [ 'expire_mon' ], $_POST [ 'expire_day' ]);
}
if ( isset ( $_POST [ 'syncMITStructural' ]) && ( $_POST [ 'syncMITStructural' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'mitKerberosStructural' ) -> setExpirationDate (
$_POST [ 'expire_yea' ], $_POST [ 'expire_mon' ], $_POST [ 'expire_day' ]);
}
2006-11-11 10:02:13 +00:00
}
elseif ( strpos ( $buttonName , '_del' ) !== false ) {
// remove attribute value
unset ( $this -> attributes [ $attr ]);
2012-02-18 13:47:49 +00:00
// sync other modules
2011-02-24 19:30:00 +00:00
if ( isset ( $_POST [ 'syncShadow' ]) && ( $_POST [ 'syncShadow' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'shadowAccount' ) -> setExpirationDate (
null , null , null );
}
2012-02-18 13:47:49 +00:00
if ( isset ( $_POST [ 'syncHeimdal' ]) && ( $_POST [ 'syncHeimdal' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'heimdalKerberos' ) -> setExpirationDate (
null , null , null );
}
2012-11-11 11:35:45 +00:00
if ( isset ( $_POST [ 'syncMIT' ]) && ( $_POST [ 'syncMIT' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'mitKerberos' ) -> setExpirationDate (
null , null , null );
}
if ( isset ( $_POST [ 'syncMITStructural' ]) && ( $_POST [ 'syncMITStructural' ] == 'on' )) {
$this -> getAccountContainer () -> getAccountModule ( 'mitKerberosStructural' ) -> setExpirationDate (
null , null , null );
}
2006-11-11 10:02:13 +00:00
}
return $return ;
}
2007-10-22 16:24:22 +00:00
/**
* Processes user input of the terminal server page .
* It checks if all input values are correct and updates the associated LDAP attributes .
*
* @ return array list of info / error messages
*/
function process_terminalServer () {
2019-11-01 20:01:08 +00:00
if ( isset ( $_POST [ 'form_subpage_sambaSamAccount_attributes_abort' ])) {
return array ();
}
2007-10-22 16:59:30 +00:00
$mDial = new sambaMungedDial ();
if ( isset ( $this -> attributes [ 'sambaMungedDial' ][ 0 ])) {
$mDial -> load ( $this -> attributes [ 'sambaMungedDial' ][ 0 ]);
}
2015-08-06 19:20:54 +00:00
$mDial -> setTsLogin ( ! isset ( $_POST [ 'tsAllowLogin' ]));
2007-10-22 16:59:30 +00:00
$mDial -> ctx [ 'CtxWFHomeDir' ] = $_POST [ 'tsHomeDir' ];
$mDial -> ctx [ 'CtxWFHomeDirDrive' ] = $_POST [ 'tsHomeDrive' ];
$mDial -> ctx [ 'CtxWFProfilePath' ] = $_POST [ 'tsProfilePath' ];
$mDial -> setInheritMode ( isset ( $_POST [ 'tsInherit' ]));
$mDial -> ctx [ 'CtxInitialProgram' ] = $_POST [ 'tsInitialProgram' ];
$mDial -> ctx [ 'CtxWorkDirectory' ] = $_POST [ 'tsWorkDirectory' ];
$mDial -> ctx [ 'CtxMaxConnectionTime' ] = $_POST [ 'tsConnectionLimit' ];
$mDial -> ctx [ 'CtxMaxDisconnectionTime' ] = $_POST [ 'tsDisconnectionLimit' ];
$mDial -> ctx [ 'CtxMaxIdleTime' ] = $_POST [ 'tsIdleLimit' ];
$mDial -> setConnectClientDrives ( isset ( $_POST [ 'tsConnectDrives' ]));
$mDial -> setConnectClientPrinters ( isset ( $_POST [ 'tsConnectPrinters' ]));
$mDial -> setDefaultPrinter ( isset ( $_POST [ 'tsClientPrinterDefault' ]));
$mDial -> setShadow ( true , $_POST [ 'tsShadowing' ]);
$mDial -> setBrokenConn ( $_POST [ 'tsBrokenConn' ]);
$mDial -> setReConn ( $_POST [ 'tsReconnect' ]);
$this -> attributes [ 'sambaMungedDial' ][ 0 ] = $mDial -> getMunged ();
return array ();
2007-10-22 16:24:22 +00:00
}
2007-11-03 14:17:19 +00:00
/**
* Returns the HTML meta data for the main account page .
2015-08-06 19:20:54 +00:00
*
2010-10-09 14:37:15 +00:00
* @ return htmlElement HTML meta data
2007-11-03 14:17:19 +00:00
*/
2006-08-14 17:24:27 +00:00
function display_html_attributes () {
2019-11-02 10:35:54 +00:00
$return = new htmlResponsiveRow ();
2012-04-09 13:20:24 +00:00
if ( $this -> isExtensionEnabled ()) {
2009-02-01 16:24:37 +00:00
if ( $this -> get_scope () == " host " ) {
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
if ( substr ( $attrs [ 'uid' ][ 0 ], - 1 , 1 ) != '$' ) {
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlStatusMessage ( " ERROR " , _ ( 'Host name must end with $!' ), _ ( 'Please check your settings on the Unix page!' )), 12 );
2009-02-01 16:24:37 +00:00
}
}
2012-01-15 15:34:12 +00:00
$personalAttributes = array ();
if ( $this -> getAccountContainer () -> getAccountModule ( 'inetOrgPerson' ) != null ) {
$personalAttributes = $this -> getAccountContainer () -> getAccountModule ( 'inetOrgPerson' ) -> getAttributes ();
}
2007-08-25 10:08:15 +00:00
// Get Domain SID from user SID
2010-11-21 19:23:12 +00:00
$sambaDomains = $this -> getDomains ();
2007-08-25 10:08:15 +00:00
if ( sizeof ( $sambaDomains ) == 0 ) {
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlStatusMessage ( " ERROR " , _ ( 'No Samba 3 domains found in LDAP! Please create one first.' )), 12 );
2010-10-09 14:37:15 +00:00
return $return ;
2006-11-11 10:02:13 +00:00
}
2008-04-24 18:57:51 +00:00
if ( isset ( $this -> attributes [ 'sambaSID' ][ 0 ]) && $this -> attributes [ 'sambaSID' ][ 0 ] != '' ) {
2007-08-25 10:08:15 +00:00
$domainSID = substr ( $this -> attributes [ 'sambaSID' ][ 0 ], 0 , strrpos ( $this -> attributes [ 'sambaSID' ][ 0 ], " - " ));
2006-11-11 10:02:13 +00:00
}
2008-04-24 18:57:51 +00:00
$sel_domain = array ();
2007-08-25 10:08:15 +00:00
for ( $i = 0 ; $i < count ( $sambaDomains ); $i ++ ) {
$sambaDomainNames [] = $sambaDomains [ $i ] -> name ;
if ( isset ( $domainSID )) {
if ( $domainSID == $sambaDomains [ $i ] -> SID ) {
$SID = $domainSID ;
2008-04-24 18:57:51 +00:00
$sel_domain = array ( $sambaDomains [ $i ] -> name );
2007-08-25 10:08:15 +00:00
}
}
elseif ( isset ( $this -> attributes [ 'sambaDomainName' ][ 0 ]) && ( $this -> attributes [ 'sambaDomainName' ][ 0 ] != '' )) {
if ( $this -> attributes [ 'sambaDomainName' ][ 0 ] == $sambaDomains [ $i ] -> name ) {
$SID = $sambaDomains [ $i ] -> SID ;
2008-04-24 18:57:51 +00:00
$sel_domain = array ( $sambaDomains [ $i ] -> name );
2007-08-25 10:08:15 +00:00
}
}
2006-11-11 10:02:13 +00:00
}
2010-10-09 14:37:15 +00:00
// display name
2007-10-15 20:39:27 +00:00
$displayName = '' ;
2014-07-27 15:51:00 +00:00
if ( ! empty ( $this -> attributes [ 'displayName' ][ 0 ])) {
2012-01-15 15:34:12 +00:00
$displayName = $this -> attributes [ 'displayName' ][ 0 ];
}
2014-07-27 15:51:00 +00:00
else if ( $this -> getAccountContainer () -> isNewAccount && empty ( $this -> attributes [ 'displayName' ][ 0 ])) {
2012-01-15 15:34:12 +00:00
if ( isset ( $personalAttributes [ 'givenName' ][ 0 ]) && $personalAttributes [ 'givenName' ][ 0 ] && isset ( $personalAttributes [ 'sn' ][ 0 ]) && $personalAttributes [ 'sn' ][ 0 ]) {
$displayName = $personalAttributes [ 'givenName' ][ 0 ] . " " . $personalAttributes [ 'sn' ][ 0 ];
}
elseif ( isset ( $personalAttributes [ 'sn' ][ 0 ])) {
$displayName = $personalAttributes [ 'sn' ][ 0 ];
}
}
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Display name' ), 'displayName' , $displayName , 'displayName' ), 12 );
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2010-10-09 14:37:15 +00:00
// user account
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlHiddenInput ( 'sambaAcctFlagsU' , 'true' ), 12 );
2010-10-09 14:37:15 +00:00
// no password
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'sambaAcctFlagsN' , $this -> nopwd , _ ( 'Use no password' ), 'noPassword' ), 12 );
2010-10-09 14:37:15 +00:00
// no password expiry
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'sambaAcctFlagsX' , $this -> noexpire , _ ( 'Password does not expire' ), 'noExpire' ), 12 );
2010-10-09 14:37:15 +00:00
// account deactivated
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'sambaAcctFlagsD' , $this -> deactivated , _ ( 'Account is deactivated' ), 'deactivated' ), 12 );
2010-10-09 14:37:15 +00:00
// account locked
2007-08-25 10:08:15 +00:00
$locked = false ;
if ( isset ( $this -> attributes [ 'sambaAcctFlags' ][ 0 ]) && ( strpos ( $this -> attributes [ 'sambaAcctFlags' ][ 0 ], " L " ) !== false )) {
$locked = true ;
2004-10-16 19:51:36 +00:00
}
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'sambaAcctFlagsL' , $locked , _ ( 'Account is locked' ), 'locked' ), 12 );
2010-10-09 14:37:15 +00:00
// password change at next login
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'forcePasswordChangeOption' , $this -> expirePassword , _ ( 'Password change at next login' ), 'passwordIsExpired' ), 12 );
2013-09-28 11:44:41 +00:00
// last password change
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideSambaPwdLastSet' )) {
$sambaPwdLastSet = '' ;
if ( ! empty ( $this -> attributes [ 'sambaPwdLastSet' ][ 0 ])) {
2015-11-07 09:14:48 +00:00
$time = new DateTime ( '@' . $this -> attributes [ 'sambaPwdLastSet' ][ 0 ], new DateTimeZone ( 'UTC' ));
$time -> setTimezone ( getTimeZone ());
2015-08-23 17:56:27 +00:00
$sambaPwdLastSet = $time -> format ( 'd.m.Y H:i' );
2013-09-28 11:44:41 +00:00
}
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Last password change' )));
$sambaPwdLastSetGroup = new htmlGroup ();
$sambaPwdLastSetGroup -> addElement ( new htmlOutputText ( $sambaPwdLastSet ));
$sambaPwdLastSetGroup -> addElement ( new htmlHelpLink ( 'sambaPwdLastSet' ));
$return -> addField ( $sambaPwdLastSetGroup );
2013-09-28 11:44:41 +00:00
}
2010-10-09 14:37:15 +00:00
// password can be changed
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'User can change password' )));
$pwdCanChangeGroup = new htmlGroup ();
$pwdCanChangeGroup -> addElement ( new htmlOutputText ( $this -> getPasswordCanChangeTime ( $sambaDomains , $sel_domain ), false ));
$pwdCanChangeGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$pwdCanChangeGroup -> addElement ( new htmlHelpLink ( 'pwdCanChange' ));
$return -> addField ( $pwdCanChangeGroup );
2010-10-09 14:37:15 +00:00
// password must be changed
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'User must change password' )));
$pwdMustChangeGroup = new htmlGroup ();
$pwdMustChangeGroup -> addElement ( new htmlOutputText ( $this -> getPasswordMustChangeTime ( $sambaDomains , $sel_domain ), false ));
$pwdMustChangeGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$pwdMustChangeGroup -> addElement ( new htmlHelpLink ( 'pwdMustChange' ));
$return -> addField ( $pwdMustChangeGroup );
2010-10-09 14:37:15 +00:00
// account expiration time
2017-04-18 16:28:10 +00:00
$dateValue = $this -> formatAccountExpirationDate ();
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Account expiration date' )));
$expireDateGroup = new htmlGroup ();
$expireDateGroup -> addElement ( new htmlOutputText ( $dateValue , false ));
$expireDateGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$expireDateGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'time' , 'sambaKickoffTime' , _ ( 'Change' )));
$expireDateGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$expireDateGroup -> addElement ( new htmlHelpLink ( 'expireDate' ), true );
$return -> addField ( $expireDateGroup );
2015-08-06 19:20:54 +00:00
// home drive
2009-10-04 17:05:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomeDrive' )) {
$drives = array ( '-' );
2019-11-01 20:01:08 +00:00
for ( $i = 90 ; $i > 67 ; $i -- ) {
$drives [] = chr ( $i ) . ':' ;
}
2009-10-04 17:05:51 +00:00
if ( isset ( $this -> attributes [ 'sambaHomeDrive' ][ 0 ])) {
$selected = array ( $this -> attributes [ 'sambaHomeDrive' ][ 0 ]);
}
2019-11-01 20:01:08 +00:00
else {
$selected = array ( '-' );
}
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveSelect ( 'sambaHomeDrive' , $drives , $selected , _ ( 'Home drive' ), 'homeDrive' ), 12 );
2007-08-25 10:08:15 +00:00
}
2010-10-09 14:37:15 +00:00
// home path
2009-10-04 17:05:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomePath' )) {
$sambaHomePath = '' ;
if ( isset ( $this -> attributes [ 'sambaHomePath' ][ 0 ])) {
$sambaHomePath = $this -> attributes [ 'sambaHomePath' ][ 0 ];
}
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Home path' ), 'sambaHomePath' , $sambaHomePath , 'homePath' ), 12 );
2007-10-22 16:24:22 +00:00
}
2019-11-02 10:35:54 +00:00
// profile path
2009-10-04 17:05:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideProfilePath' )) {
$sambaProfilePath = '' ;
if ( isset ( $this -> attributes [ 'sambaProfilePath' ][ 0 ])) {
$sambaProfilePath = $this -> attributes [ 'sambaProfilePath' ][ 0 ];
}
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Profile path' )));
2013-02-27 18:56:23 +00:00
$sambaProfilePathGroup = new htmlGroup ();
$sambaProfilePathGroup -> addElement ( new htmlInputField ( 'sambaProfilePath' , $sambaProfilePath ));
if (( $_SESSION [ 'config' ] -> get_scriptPath () != null ) && ( $_SESSION [ 'config' ] -> get_scriptPath () != '' )) {
if ( get_preg ( $sambaProfilePath , 'homeDirectory' )) {
$sambaProfilePathButton = new htmlAccountPageButton ( get_class ( $this ), 'profilePath' , 'manage' , '../graphics/folder.png' , true );
$sambaProfilePathButton -> setTitle ( _ ( 'Manage profile directory' ));
$sambaProfilePathGroup -> addElement ( $sambaProfilePathButton );
}
}
2019-11-02 10:35:54 +00:00
$sambaProfilePathGroup -> addElement ( new htmlHelpLink ( 'profilePath' ));
$return -> addField ( $sambaProfilePathGroup );
2007-10-22 16:24:22 +00:00
}
2010-10-09 14:37:15 +00:00
// logon script
2009-10-04 17:05:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonScript' )) {
$sambaLogonScript = '' ;
if ( isset ( $this -> attributes [ 'sambaLogonScript' ][ 0 ])) {
$sambaLogonScript = $this -> attributes [ 'sambaLogonScript' ][ 0 ];
}
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Logon script' ), 'sambaLogonScript' , $sambaLogonScript , 'scriptPath' ), 12 );
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideWorkstations' )) {
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Samba workstations' )));
$userWorkstationsGroup = new htmlGroup ();
$userWorkstationsGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'sambaUserWorkstations' , 'open' , _ ( 'Edit workstations' )));
$userWorkstationsGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$userWorkstationsGroup -> addElement ( new htmlHelpLink ( 'userWorkstations' ));
$return -> addField ( $userWorkstationsGroup );
2007-10-22 16:24:22 +00:00
}
2010-10-09 14:37:15 +00:00
// Windows group
2012-11-02 18:05:37 +00:00
$names = array_keys ( $this -> groupRids );
2007-08-25 10:08:15 +00:00
$wrid = false ;
$options = array ();
$selected = array ();
for ( $i = 0 ; $i < count ( $names ); $i ++ ) {
2012-11-02 18:05:37 +00:00
if ( isset ( $this -> attributes [ 'sambaPrimaryGroupSID' ][ 0 ]) && ( $this -> attributes [ 'sambaPrimaryGroupSID' ][ 0 ] == $SID . " - " . $this -> groupRids [ $names [ $i ]])) {
2007-08-25 10:08:15 +00:00
$selected [] = $names [ $i ];
$wrid = true ;
}
2010-10-09 14:37:15 +00:00
$options [] = $names [ $i ];
2007-08-25 10:08:15 +00:00
}
2007-10-10 19:04:39 +00:00
$attrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
2010-10-09 14:37:15 +00:00
$options [] = $this -> getGroupName ( $attrs [ 'gidNumber' ][ 0 ]);
if ( ! $wrid ) {
$selected [] = $this -> getGroupName ( $attrs [ 'gidNumber' ][ 0 ]);
}
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveSelect ( 'sambaPrimaryGroupSID' , $options , $selected , _ ( 'Windows group' ), 'group' ), 12 );
2007-08-25 10:08:15 +00:00
// display if group SID should be mapped to a well known SID
2012-11-02 18:05:37 +00:00
$options = array_keys ( $this -> userRids );
2007-08-25 10:08:15 +00:00
$options [] = '-' ;
$selected = array ();
2008-04-24 18:57:51 +00:00
if ( isset ( $this -> attributes [ 'sambaSID' ][ 0 ]) && ( $this -> attributes [ 'sambaSID' ][ 0 ] != '' )) {
2007-08-25 10:08:15 +00:00
$rid = substr ( $this -> attributes [ 'sambaSID' ][ 0 ], strrpos ( $this -> attributes [ 'sambaSID' ][ 0 ], '-' ) + 1 , strlen ( $this -> attributes [ 'sambaSID' ][ 0 ]));
2012-11-02 18:05:37 +00:00
$specialRids = array_flip ( $this -> userRids );
if ( in_array ( $rid , $this -> userRids )) {
2007-08-25 10:08:15 +00:00
$selected = array ( $specialRids [ $rid ]);
}
else {
$selected = array ( '-' );
}
}
2019-11-01 20:01:08 +00:00
else {
$selected [] = " - " ;
}
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveSelect ( 'sambaSID' , $options , $selected , _ ( 'Special user' ), 'specialUser' ), 12 );
2010-10-09 14:37:15 +00:00
}
// domain
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlResponsiveSelect ( 'sambaDomainName' , $sambaDomainNames , $sel_domain , _ ( 'Domain' ), 'domain' ), 12 );
2007-10-22 16:24:22 +00:00
// logon hours and terminal server options
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'user' ) {
2009-10-04 17:05:51 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonHours' )) {
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Logon hours' )));
$logonHoursGroup = new htmlGroup ();
$logonHoursGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'logonHours' , 'open' , _ ( 'Edit' )));
$logonHoursGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$logonHoursGroup -> addElement ( new htmlHelpLink ( 'logonHours' ));
$return -> addField ( $logonHoursGroup );
2009-10-04 17:05:51 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideTerminalServer' )) {
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Terminal server options' )));
$terminalServerGroup = new htmlGroup ();
$terminalServerGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'terminalServer' , 'open' , _ ( 'Edit' )));
$terminalServerGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$terminalServerGroup -> addElement ( new htmlHelpLink ( 'terminalServer' ));
$return -> addField ( $terminalServerGroup );
2009-10-04 17:05:51 +00:00
}
2005-06-30 16:22:58 +00:00
}
2007-08-25 10:08:15 +00:00
// reset host password
2007-10-04 16:45:05 +00:00
if ( $this -> get_scope () == 'host' ) {
2010-10-09 14:37:15 +00:00
// host account
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlHiddenInput ( 'sambaAcctFlagsW' , 'true' ), 12 );
2010-10-09 14:37:15 +00:00
// password reset
2019-11-02 10:35:54 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Reset password' )));
$resetPasswordGroup = new htmlGroup ();
$resetPasswordGroup -> addElement ( new htmlButton ( 'ResetSambaPassword' , _ ( 'Reset' )));
$resetPasswordGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$resetPasswordGroup -> addElement ( new htmlHelpLink ( 'resetPassword' ));
$return -> addField ( $resetPasswordGroup );
2009-12-20 14:35:42 +00:00
}
2010-10-09 14:37:15 +00:00
2019-11-02 10:35:54 +00:00
$return -> addVerticalSpacer ( '2rem' );
2015-08-06 19:20:54 +00:00
2010-10-09 14:37:15 +00:00
$remButton = new htmlButton ( 'remObjectClass' , _ ( 'Remove Samba 3 extension' ));
2019-11-02 10:35:54 +00:00
$return -> add ( $remButton , 12 , 12 , 12 , 'text-center' );
2007-08-25 10:08:15 +00:00
}
else {
2019-11-02 10:35:54 +00:00
$return -> add ( new htmlButton ( 'addObjectClass' , _ ( 'Add Samba 3 extension' )), 12 );
2005-07-07 13:35:29 +00:00
}
2004-01-27 19:07:31 +00:00
return $return ;
2006-05-18 08:30:22 +00:00
}
2003-12-20 21:42:52 +00:00
2017-04-18 16:28:10 +00:00
/**
* Returns the account expiration date in printable form .
*
* @ return string expiration date
*/
private function formatAccountExpirationDate () {
$dateValue = " - " ;
if ( isset ( $this -> attributes [ 'sambaKickoffTime' ][ 0 ])) {
if ( $this -> attributes [ 'sambaKickoffTime' ][ 0 ] > 2147483648 ) {
$dateValue = " ∞ " ;
}
else {
$date = new DateTime ( '@' . $this -> attributes [ 'sambaKickoffTime' ][ 0 ], new DateTimeZone ( 'UTC' ));
$dateValue = $date -> format ( 'd.m.Y' );
}
}
return $dateValue ;
}
2007-11-03 14:17:19 +00:00
/**
* This function will create the HTML page to edit the allowed workstations .
*
2010-09-28 18:36:22 +00:00
* @ return htmlElement meta HTML code
2003-12-20 21:42:52 +00:00
*/
2006-08-14 17:24:27 +00:00
function display_html_sambaUserWorkstations () {
2019-11-01 19:58:22 +00:00
$return = new htmlResponsiveRow ();
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.
2010-09-28 18:36:22 +00:00
$userWorkstations = array ();
$availableUserWorkstations = array ();
2015-08-06 19:20:54 +00:00
2010-11-21 14:32:42 +00:00
$result = $this -> getHostList ();
2019-11-01 19:58:22 +00:00
foreach ( $result as $host ) {
$availableUserWorkstations [] = str_replace ( " $ " , '' , $host );
}
2010-11-21 14:32:42 +00:00
sort ( $availableUserWorkstations , SORT_STRING );
if ( isset ( $this -> attributes [ 'sambaUserWorkstations' ][ 0 ])) {
$wsAttr = str_replace ( ' ' , '' , $this -> attributes [ 'sambaUserWorkstations' ][ 0 ]);
$userWorkstations = explode ( ',' , $wsAttr );
}
$availableUserWorkstations = array_delete ( $userWorkstations , $availableUserWorkstations );
2004-01-27 19:07:31 +00:00
2019-11-01 19:58:22 +00:00
$return -> add ( new htmlSubTitle ( _ ( " Allowed workstations " )), 12 );
2015-08-06 19:20:54 +00:00
2019-11-01 19:58:22 +00:00
$userWorkstationsOptions = array ();
foreach ( $userWorkstations as $userWorkstation ) {
$userWorkstationsOptions [ $userWorkstation ] = $userWorkstation ;
}
$availableUserWorkstationsOptions = array ();
foreach ( $availableUserWorkstations as $availableUserWorkstation ) {
$availableUserWorkstationsOptions [ $availableUserWorkstation ] = $availableUserWorkstation ;
}
$this -> addDoubleSelectionArea ( $return , _ ( " Allowed workstations " ), _ ( " Available workstations " ), $userWorkstationsOptions , array (), $availableUserWorkstationsOptions , array (), 'workstations' , false , true );
$return -> addVerticalSpacer ( '2rem' );
2015-08-06 19:20:54 +00:00
2010-09-28 18:36:22 +00:00
$backButton = new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'back' , _ ( 'Back' ));
2019-11-01 19:58:22 +00:00
$return -> add ( $backButton , 12 );
2019-11-01 20:01:08 +00:00
}
2004-01-27 19:07:31 +00:00
return $return ;
2006-05-18 08:30:22 +00:00
}
2003-12-20 21:42:52 +00:00
2005-07-07 13:35:29 +00:00
/**
* This function will create the HTML page to edit logon hours .
*
2010-09-28 18:36:22 +00:00
* @ return htmlElement meta HTML code
2005-07-07 13:35:29 +00:00
*/
2006-08-14 17:24:27 +00:00
function display_html_logonHours () {
2019-11-01 19:58:22 +00:00
$return = new htmlResponsiveRow ();
2015-06-08 18:33:38 +00:00
$timeZone = getTimeZoneOffsetHours ();
2019-11-01 19:58:22 +00:00
$titles = array ( _ ( 'Time' ), _ ( 'Sunday' ), _ ( 'Monday' ), _ ( 'Tuesday' ), _ ( 'Wednesday' ), _ ( 'Thursday' ),
_ ( 'Friday' ), _ ( 'Saturday' ));
$data = array ();
2010-09-28 18:36:22 +00:00
if ( ! isset ( $this -> attributes [ 'sambaLogonHours' ][ 0 ]) || ( $this -> attributes [ 'sambaLogonHours' ][ 0 ] == '' )) {
2005-07-07 13:35:29 +00:00
$this -> attributes [ 'sambaLogonHours' ][ 0 ] = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' ;
}
// convert existing logonHours string to bit array
$logonHours = $this -> attributes [ 'sambaLogonHours' ][ 0 ];
$temp = array ();
for ( $i = 0 ; $i < strlen ( $logonHours ); $i ++ ) {
$temp [] = $this -> hex2bitstring [ $logonHours [ $i ]];
}
2005-10-09 10:32:21 +00:00
$logonHoursRev = implode ( '' , $temp );
// reverse bits low to high (1 is 0:00 sunday, 2 is 1:00 sunday, etc)
$logonHours = " " ;
for ( $i = 0 ; $i < 21 ; $i ++ ) {
$logonHours .= strrev ( substr ( $logonHoursRev , $i * 8 , 8 ));
}
$hour = array ();
for ( $i = 0 ; $i < 24 * 7 ; $i ++ ) {
$hour [ $i ] = substr ( $logonHours , $i , 1 );
2005-07-07 13:35:29 +00:00
}
// display input
2010-09-28 18:36:22 +00:00
$boxes = array ();
// dynamically place boxes depending on time zone
2005-10-09 10:32:21 +00:00
for ( $i = 0 ; $i < 24 * 7 ; $i ++ ) {
2006-03-15 14:12:59 +00:00
$hr = $i + $timeZone ;
if ( $hr < 0 ) {
$hr = $hr + 24 * 7 ;
}
elseif ( $hr >= 24 * 7 ) {
$hr = $hr - 24 * 7 ;
}
2019-10-15 14:15:12 +00:00
$checkbox = new htmlInputCheckbox ( 'lh_' . $hr , $hour [ $hr ]);
2010-09-28 18:36:22 +00:00
$boxes [ $i % 24 ][ floor ( $i / 24 )] = $checkbox ;
2005-07-07 13:35:29 +00:00
}
for ( $h = 0 ; $h < 24 ; $h ++ ) {
2010-09-28 18:36:22 +00:00
$hour = $h ;
if ( $h < 10 ) {
$hour = '0' . $h ;
}
2019-11-01 19:58:22 +00:00
$row = array ();
$row [] = new htmlOutputText ( " $hour :00 - $hour :59 " );
2010-09-28 18:36:22 +00:00
for ( $d = 0 ; $d < 7 ; $d ++ ) {
2019-11-01 19:58:22 +00:00
$row [] = $boxes [ $h ][ $d ];
2010-09-28 18:36:22 +00:00
}
2019-11-01 19:58:22 +00:00
$data [] = $row ;
2005-07-07 13:35:29 +00:00
}
2019-11-01 19:58:22 +00:00
$return -> add ( new htmlResponsiveTable ( $titles , $data ), 12 );
2015-08-06 19:20:54 +00:00
2019-11-01 19:58:22 +00:00
$return -> addVerticalSpacer ( '2rem' );
$return -> addLabel ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'submit' , _ ( 'Ok' )));
$return -> addField ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'abort' , _ ( 'Cancel' )));
2005-07-07 13:35:29 +00:00
return $return ;
}
2006-11-11 10:02:13 +00:00
/**
* This function will create the meta HTML code to show a page to change time values .
*
2010-09-28 18:36:22 +00:00
* @ return htmlElement meta HTML code
2006-11-11 10:02:13 +00:00
*/
function display_html_time () {
2019-11-02 09:44:28 +00:00
$return = new htmlResponsiveRow ();
2016-07-18 18:58:47 +00:00
$attr = 'sambaKickoffTime' ;
$text = _ ( 'Account expiration date' );
$help = " expireDate " ;
$time = time () + 3600 * 24 * 365 ;
2006-11-11 10:02:13 +00:00
if ( isset ( $this -> attributes [ $attr ][ 0 ])) {
$time = $this -> attributes [ $attr ][ 0 ];
}
2016-07-18 18:58:47 +00:00
$date = new DateTime ( '@' . $time , new DateTimeZone ( 'UTC' ));
2019-11-01 20:01:08 +00:00
for ( $i = 1 ; $i <= 31 ; $i ++ ) {
$mday [] = $i ;
}
for ( $i = 1 ; $i <= 12 ; $i ++ ) {
$mon [] = $i ;
}
for ( $i = 2003 ; $i <= 2050 ; $i ++ ) {
$year [] = $i ;
}
2019-11-02 09:44:28 +00:00
$return -> addLabel ( new htmlOutputText ( $text ));
$dateGroup = new htmlGroup ();
$daySelect = new htmlSelect ( 'expire_day' , $mday , array ( $date -> format ( 'j' )));
$daySelect -> setWidth ( '3rem' );
$dateGroup -> addElement ( $daySelect );
$monthSelect = new htmlSelect ( 'expire_mon' , $mon , array ( $date -> format ( 'n' )));
$monthSelect -> setWidth ( '3rem' );
$dateGroup -> addElement ( $monthSelect );
$yearSelect = new htmlSelect ( 'expire_yea' , $year , array ( $date -> format ( 'Y' )));
$yearSelect -> setWidth ( '5rem' );
$dateGroup -> addElement ( $yearSelect );
$dateGroup -> addElement ( new htmlHelpLink ( $help ));
$return -> addField ( $dateGroup );
2011-02-24 19:30:00 +00:00
if ( $this -> getAccountContainer () -> getAccountModule ( 'shadowAccount' ) != null ) {
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'syncShadow' , false , _ ( 'Set also for Shadow' )), 12 );
2011-02-24 19:30:00 +00:00
}
2012-02-18 13:47:49 +00:00
if ( $this -> getAccountContainer () -> getAccountModule ( 'heimdalKerberos' ) != null ) {
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'syncHeimdal' , false , _ ( 'Set also for Kerberos' )), 12 );
2012-02-18 13:47:49 +00:00
}
2012-11-11 11:35:45 +00:00
if ( $this -> getAccountContainer () -> getAccountModule ( 'mitKerberos' ) != null ) {
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'syncMIT' , false , _ ( 'Set also for Kerberos' )), 12 );
2012-11-11 11:35:45 +00:00
}
if ( $this -> getAccountContainer () -> getAccountModule ( 'mitKerberosStructural' ) != null ) {
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'syncMITStructural' , false , _ ( 'Set also for Kerberos' )), 12 );
2012-11-11 11:35:45 +00:00
}
2019-11-02 09:44:28 +00:00
$return -> addVerticalSpacer ( '2rem' );
$buttons = new htmlGroup ();
2010-10-09 14:37:15 +00:00
$buttons -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'change' . $attr , _ ( 'Change' )));
2019-11-02 09:44:28 +00:00
$buttons -> addElement ( new htmlSpacer ( '0.5rem' , null ));
2006-11-11 10:02:13 +00:00
if ( isset ( $this -> attributes [ $attr ][ 0 ])) {
2010-10-09 14:37:15 +00:00
$buttons -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'del' . $attr , _ ( 'Remove' )));
2019-11-02 09:44:28 +00:00
$buttons -> addElement ( new htmlSpacer ( '0.5rem' , null ));
2006-11-11 10:02:13 +00:00
}
2010-10-09 14:37:15 +00:00
$buttons -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'back' . $attr , _ ( 'Cancel' )));
2019-11-02 09:44:28 +00:00
$return -> add ( $buttons , 12 , 12 , 12 , 'text-center' );
2015-08-06 19:20:54 +00:00
return $return ;
2006-11-11 10:02:13 +00:00
}
2007-10-22 16:24:22 +00:00
/**
* This function will create the HTML page to edit the terminal server options .
*
2010-10-09 14:37:15 +00:00
* @ return htmlElement meta HTML code
2007-10-22 16:24:22 +00:00
*/
function display_html_terminalServer () {
2019-11-02 09:44:28 +00:00
$return = new htmlResponsiveRow ();
2007-10-22 16:24:22 +00:00
$mDial = new sambaMungedDial ();
if ( isset ( $this -> attributes [ 'sambaMungedDial' ][ 0 ])) {
$mDial -> load ( $this -> attributes [ 'sambaMungedDial' ][ 0 ]);
}
// terminal server login
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'tsAllowLogin' , $mDial -> getTsLogin (), _ ( 'Allow terminal server login' ), 'tsAllowLogin' ), 12 );
2007-10-22 16:24:22 +00:00
// home directory
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Home directory' ), 'tsHomeDir' , $mDial -> ctx [ 'CtxWFHomeDir' ], 'tsHomeDir' ), 12 );
2007-10-22 16:24:22 +00:00
// home drive
$drives = array ();
2019-11-01 20:01:08 +00:00
for ( $i = 90 ; $i > 67 ; $i -- ) {
$drives [] = chr ( $i ) . ':' ;
}
2007-10-22 16:24:22 +00:00
$selTsDrive = array ();
if ( isset ( $mDial -> ctx [ 'CtxWFHomeDirDrive' ])) {
$selTsDrive = array ( $mDial -> ctx [ 'CtxWFHomeDirDrive' ]);
}
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveSelect ( 'tsHomeDrive' , $drives , $selTsDrive , _ ( 'Home drive' ), 'homeDrive' ), 12 );
2007-10-22 16:24:22 +00:00
// profile path
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Profile path' ), 'tsProfilePath' , $mDial -> ctx [ 'CtxWFProfilePath' ], 'tsProfilePath' ), 12 );
2007-10-22 16:24:22 +00:00
// use startup program and working dir from client
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'tsInherit' , $mDial -> getInheritMode (), _ ( 'Inherit client startup configuration' ), 'tsInherit' ), 12 );
2007-10-22 16:24:22 +00:00
// startup program
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Initial program' ), 'tsInitialProgram' , $mDial -> ctx [ 'CtxInitialProgram' ], 'tsInitialProgram' ), 12 );
2007-10-22 16:24:22 +00:00
// working dir
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Working directory' ), 'tsWorkDirectory' , $mDial -> ctx [ 'CtxWorkDirectory' ], 'tsWorkDirectory' ), 12 );
2007-10-22 16:24:22 +00:00
// connection time limit
2019-11-02 09:44:28 +00:00
$tsConnectionLimit = new htmlResponsiveInputField ( _ ( 'Connection time limit' ), 'tsConnectionLimit' , $mDial -> ctx [ 'CtxMaxConnectionTime' ], 'tsTimeLimit' );
2011-10-19 17:57:57 +00:00
$tsConnectionLimit -> setValidationRule ( htmlElement :: VALIDATE_NUMERIC );
2019-11-02 09:44:28 +00:00
$return -> add ( $tsConnectionLimit , 12 );
2007-10-22 16:24:22 +00:00
// disconnection time limit
2019-11-02 09:44:28 +00:00
$tsDisconnectionLimit = new htmlResponsiveInputField ( _ ( 'Disconnection time limit' ), 'tsDisconnectionLimit' , $mDial -> ctx [ 'CtxMaxDisconnectionTime' ], 'tsTimeLimit' );
2011-10-19 17:57:57 +00:00
$tsDisconnectionLimit -> setValidationRule ( htmlElement :: VALIDATE_NUMERIC );
2019-11-02 09:44:28 +00:00
$return -> add ( $tsDisconnectionLimit , 12 );
2007-10-22 16:24:22 +00:00
// idle time limit
2019-11-02 09:44:28 +00:00
$tsIdleLimit = new htmlResponsiveInputField ( _ ( 'Idle time limit' ), 'tsIdleLimit' , $mDial -> ctx [ 'CtxMaxIdleTime' ], 'tsTimeLimit' );
2011-10-19 17:57:57 +00:00
$tsIdleLimit -> setValidationRule ( htmlElement :: VALIDATE_NUMERIC );
2019-11-02 09:44:28 +00:00
$return -> add ( $tsIdleLimit , 12 );
2007-10-22 16:24:22 +00:00
// connect client drives
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'tsConnectDrives' , $mDial -> getConnectClientDrives (), _ ( 'Connect client drives' ), 'tsConnectDrives' ), 12 );
2007-10-22 16:24:22 +00:00
// connect client printers
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'tsConnectPrinters' , $mDial -> getConnectClientPrinters (), _ ( 'Connect client printers' ), 'tsConnectPrinters' ), 12 );
2007-10-22 16:24:22 +00:00
// client printer is default
2019-11-02 09:44:28 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'tsClientPrinterDefault' , $mDial -> getDefaultPrinter (), _ ( 'Client printer is default' ), 'tsClientPrinterDefault' ), 12 );
2007-10-22 16:24:22 +00:00
// shadowing
$shadowOptions = array (
2010-10-09 14:37:15 +00:00
_ ( " disabled " ) => " 0 " ,
_ ( " input on, notify on " ) => " 1 " ,
_ ( " input on, notify off " ) => " 2 " ,
_ ( " input off, notify on " ) => " 3 " ,
_ ( " input off, notify off " ) => " 4 " );
2007-10-22 16:24:22 +00:00
$selShadow = array ( $mDial -> getShadow ());
2019-11-02 09:44:28 +00:00
$shadowSelect = new htmlResponsiveSelect ( 'tsShadowing' , $shadowOptions , $selShadow , _ ( 'Shadowing' ), 'tsShadowing' );
2010-10-09 14:37:15 +00:00
$shadowSelect -> setHasDescriptiveElements ( true );
2019-11-02 09:44:28 +00:00
$return -> add ( $shadowSelect , 12 );
2007-10-22 16:24:22 +00:00
// broken connection
$brokenConnOptions = array (
2010-10-09 14:37:15 +00:00
_ ( " disconnect " ) => " 0 " ,
_ ( " reset " ) => " 1 " );
2007-10-22 16:24:22 +00:00
$selbrokenConn = array ( $mDial -> getBrokenConn ());
2019-11-02 09:44:28 +00:00
$brokenConnSelect = new htmlResponsiveSelect ( 'tsBrokenConn' , $brokenConnOptions , $selbrokenConn , _ ( 'On broken or timed out connection' ), 'tsBrokenConn' );
2010-10-09 14:37:15 +00:00
$brokenConnSelect -> setHasDescriptiveElements ( true );
2019-11-02 09:44:28 +00:00
$return -> add ( $brokenConnSelect , 12 );
2007-10-22 16:24:22 +00:00
// reconnect
$reconnectOptions = array (
2010-10-09 14:37:15 +00:00
_ ( " from any client " ) => " 0 " ,
_ ( " from previous client only " ) => " 1 " );
2007-10-22 16:24:22 +00:00
$selReconnect = array ( $mDial -> getReConn ());
2019-11-02 09:44:28 +00:00
$reconnectSelect = new htmlResponsiveSelect ( 'tsReconnect' , $reconnectOptions , $selReconnect , _ ( 'Reconnect if disconnected' ), 'tsReconnect' );
2010-10-09 14:37:15 +00:00
$reconnectSelect -> setHasDescriptiveElements ( true );
2019-11-02 09:44:28 +00:00
$return -> add ( $reconnectSelect , 12 );
2007-10-22 16:24:22 +00:00
// buttons
2019-11-02 09:44:28 +00:00
$return -> addVerticalSpacer ( '2rem' );
$return -> addLabel ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'submit' , _ ( 'Ok' )));
$return -> addField ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'abort' , _ ( 'Cancel' )));
2015-08-06 19:20:54 +00:00
return $return ;
2007-10-22 16:24:22 +00:00
}
2015-08-06 19:20:54 +00:00
2013-02-27 18:56:23 +00:00
/**
* Displays manage profile path page .
*
* @ return htmlElement meta HTML code
*/
function display_html_profilePath () {
2019-11-02 09:44:28 +00:00
$return = new htmlResponsiveRow ();
$return -> addLabel ( new htmlOutputText ( _ ( 'Profile path' )));
$return -> addField ( new htmlOutputText ( $this -> attributes [ 'sambaProfilePath' ][ 0 ]));
$return -> addVerticalSpacer ( '2rem' );
2017-09-16 14:55:21 +00:00
// get list of remote servers
2019-10-17 19:18:13 +00:00
$remoteServers = $_SESSION [ 'config' ] -> getConfiguredScriptServers ();
2017-09-16 14:55:21 +00:00
for ( $i = 0 ; $i < sizeof ( $remoteServers ); $i ++ ) {
2019-10-17 19:18:13 +00:00
$remoteServer = $remoteServers [ $i ];
$label = $remoteServer -> getLabel ();
2017-09-16 14:55:21 +00:00
$remote = new \LAM\REMOTE\Remote ();
2019-10-23 19:25:33 +00:00
$remote -> connect ( $remoteServer );
2017-09-16 14:55:21 +00:00
$result = $remote -> execute (
2013-02-27 18:56:23 +00:00
implode (
self :: $SPLIT_DELIMITER ,
array (
$this -> attributes [ 'uid' ][ 0 ],
" home " ,
" check " ,
2019-10-26 15:28:24 +00:00
$remoteServer -> getHomeDirPrefix () . $this -> attributes [ 'sambaProfilePath' ][ 0 ])
2017-09-16 14:55:21 +00:00
));
$remote -> disconnect ();
// remote command results
if ( ! empty ( $result )) {
$returnValue = trim ( $result );
2013-02-27 18:56:23 +00:00
if ( $returnValue == 'ok' ) {
2019-11-02 09:44:28 +00:00
$return -> addLabel ( new htmlOutputText ( $label ));
$editGroup = new htmlGroup ();
$editGroup -> addElement ( new htmlImage ( '../../graphics/pass.png' , 16 , 16 ));
$editGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$editGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'homedir' , 'delete_' . $i , _ ( 'Delete' )));
$return -> addField ( $editGroup );
2013-02-27 18:56:23 +00:00
}
elseif ( $returnValue == 'missing' ) {
2019-11-02 09:44:28 +00:00
$return -> addLabel ( new htmlOutputText ( $label ));
$editGroup = new htmlGroup ();
$editGroup -> addElement ( new htmlImage ( '../../graphics/fail.png' , 16 , 16 ));
$editGroup -> addElement ( new htmlSpacer ( '0.5rem' , null ));
$editGroup -> addElement ( new htmlAccountPageButton ( get_class ( $this ), 'homedir' , 'create_' . $i , _ ( 'Create' )));
$return -> addField ( $editGroup );
2013-02-27 18:56:23 +00:00
}
elseif ( trim ( $returnValue ) != '' ) {
$messageParams = explode ( " , " , $returnValue );
if ( isset ( $messageParams [ 2 ])) {
$message = new htmlStatusMessage ( $messageParams [ 0 ], htmlspecialchars ( $messageParams [ 1 ]), htmlspecialchars ( $messageParams [ 2 ]));
}
elseif (( $messageParams [ 0 ] == 'ERROR' ) || ( $messageParams [ 0 ] == 'WARN' ) || ( $messageParams [ 0 ] == 'INFO' )) {
$message = new htmlStatusMessage ( $messageParams [ 0 ], htmlspecialchars ( $messageParams [ 1 ]));
}
else {
$message = new htmlStatusMessage ( 'WARN' , htmlspecialchars ( $messageParams [ 0 ]));
}
2019-11-02 09:44:28 +00:00
$return -> add ( $message , 12 );
2013-02-27 18:56:23 +00:00
}
}
}
2019-11-02 09:44:28 +00:00
$return -> addVerticalSpacer ( '2rem' );
$return -> add ( new htmlAccountPageButton ( get_class ( $this ), 'attributes' , 'back' , _ ( 'Back' )), 12 , 12 , 12 , 'text-center' );
2013-02-27 18:56:23 +00:00
return $return ;
}
/**
* Processes user input of the profile path check page .
* It checks if all input values are correct and updates the associated LDAP attributes .
*
* @ return array list of info / error messages
*/
function process_profilePath () {
$return = array ();
$unixAttrs = $this -> getAccountContainer () -> getAccountModule ( 'posixAccount' ) -> getAttributes ();
$uidNumber = $unixAttrs [ 'uidNumber' ][ 0 ];
$gidNumber = $unixAttrs [ 'gidNumber' ][ 0 ];
if ( empty ( $uidNumber ) || empty ( $gidNumber )) {
return ;
}
2017-09-16 14:55:21 +00:00
// get list of remote servers
2019-10-17 19:18:13 +00:00
$remoteServers = $_SESSION [ 'config' ] -> getConfiguredScriptServers ();
2017-09-16 14:55:21 +00:00
for ( $i = 0 ; $i < sizeof ( $remoteServers ); $i ++ ) {
2019-10-17 19:18:13 +00:00
$remoteServer = $remoteServers [ $i ];
2013-02-27 18:56:23 +00:00
if ( isset ( $_POST [ 'form_subpage_' . get_class ( $this ) . '_homedir_create_' . $i ])) {
2017-09-16 14:55:21 +00:00
$remote = new \LAM\REMOTE\Remote ();
2019-10-23 19:25:33 +00:00
$remote -> connect ( $remoteServer );
2017-09-16 14:55:21 +00:00
$result = $remote -> execute (
2013-02-27 18:56:23 +00:00
implode (
self :: $SPLIT_DELIMITER ,
array (
$this -> attributes [ 'uid' ][ 0 ],
" directory " ,
" add " ,
2019-10-26 15:28:24 +00:00
$remoteServer -> getHomeDirPrefix () . $this -> attributes [ 'sambaProfilePath' ][ 0 ],
2013-02-27 18:56:23 +00:00
" 0 " . $_SESSION [ 'config' ] -> get_scriptRights (),
$uidNumber ,
$gidNumber )
2017-09-16 14:55:21 +00:00
));
$remote -> disconnect ();
// remote command results
if ( ! empty ( $result )) {
$singleresult = explode ( " , " , $result );
2019-10-17 19:18:13 +00:00
if ( is_array ( $singleresult )
&& (( $singleresult [ 0 ] == 'ERROR' ) || ( $singleresult [ 0 ] == 'WARN' ) || ( $singleresult [ 0 ] == 'INFO' ))) {
$return [] = $singleresult ;
2013-02-27 18:56:23 +00:00
}
}
}
elseif ( isset ( $_POST [ 'form_subpage_' . get_class ( $this ) . '_homedir_delete_' . $i ])) {
2017-09-16 14:55:21 +00:00
$remote = new \LAM\REMOTE\Remote ();
2019-10-23 19:25:33 +00:00
$remote -> connect ( $remoteServer );
2017-09-16 14:55:21 +00:00
$result = $remote -> execute (
2013-02-27 18:56:23 +00:00
implode (
self :: $SPLIT_DELIMITER ,
array (
$this -> attributes [ 'uid' ][ 0 ],
" home " ,
" rem " ,
2019-10-26 15:28:24 +00:00
$remoteServer -> getHomeDirPrefix () . $this -> attributes [ 'sambaProfilePath' ][ 0 ],
2013-02-27 18:56:23 +00:00
$uidNumber
)
2017-09-16 14:55:21 +00:00
));
$remote -> disconnect ();
// remote command results
if ( ! empty ( $result )) {
$singleresult = explode ( " , " , $result );
2019-10-17 19:18:13 +00:00
if ( is_array ( $singleresult )
&& (( $singleresult [ 0 ] == 'ERROR' ) || ( $singleresult [ 0 ] == 'WARN' ) || ( $singleresult [ 0 ] == 'INFO' ))) {
$return [] = $singleresult ;
2013-02-27 18:56:23 +00:00
}
}
}
}
return $return ;
}
2004-09-19 08:35:01 +00:00
/**
2017-03-30 18:39:24 +00:00
* { @ inheritDoc }
2004-09-19 08:35:01 +00:00
*/
2017-03-30 18:39:24 +00:00
function get_profileOptions ( $typeId ) {
$return = parent :: get_profileOptions ( $typeId );
2004-11-20 12:44:56 +00:00
if ( $this -> get_scope () == 'user' ) {
2005-10-01 07:26:32 +00:00
// lists for expiration date
2019-05-12 18:51:12 +00:00
$day = array ();
$mon = array ();
$year = array ();
for ( $i = 1 ; $i <= 31 ; $i ++ ) {
$day [] = $i ;
}
for ( $i = 1 ; $i <= 12 ; $i ++ ) {
$mon [] = $i ;
}
for ( $i = 2003 ; $i <= 2030 ; $i ++ ) {
$year [] = $i ;
}
2014-07-27 15:51:00 +00:00
// display name
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Display name' ), 'sambaSamAccount_displayName' , '' , 'displayName' ), 12 );
2004-04-11 13:07:24 +00:00
// use no password at all
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_sambaAcctFlagsN' , false , _ ( 'Use no password' ), 'noPassword' ), 12 );
2005-10-01 07:26:32 +00:00
// account deactivation
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_sambaAcctFlagsD' , false , _ ( 'Account is deactivated' ), 'deactivated' ), 12 );
2004-04-11 13:07:24 +00:00
// password never expires
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_sambaAcctFlagsX' , false , _ ( 'Password does not expire' ), 'noExpire' ), 12 );
2005-10-01 07:26:32 +00:00
// expiration date
2018-05-19 09:14:31 +00:00
$return -> addLabel ( new htmlOutputText ( _ ( 'Account expiration date' )));
$expireContainer = new htmlResponsiveRow ();
$expireContainer -> add ( new htmlSelect ( 'sambaSamAccount_expire_day' , $day , array ( '1' )), 2 , 2 , 2 , 'padding-right05' );
$expireContainer -> add ( new htmlSelect ( 'sambaSamAccount_expire_mon' , $mon , array ( '1' )), 2 , 2 , 2 , 'padding-left-right05' );
$expireContainer -> add ( new htmlSelect ( 'sambaSamAccount_expire_yea' , $year , array ( '2030' )), 6 , 6 , 6 , 'padding-left-right05' );
$expireContainer -> add ( new htmlHelpLink ( 'expireDate' ), 2 , 2 , 2 , 'padding-left-right05' );
$return -> addField ( $expireContainer , 12 );
2009-10-03 18:27:17 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomeDrive' )) {
// letter of home drive
$drives = array ( '-' );
2019-05-12 18:51:12 +00:00
for ( $i = 90 ; $i > 67 ; $i -- ) {
$drives [] = chr ( $i ) . ':' ;
}
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveSelect ( 'sambaSamAccount_sambaHomeDrive' , $drives , array ( '-' ), _ ( 'Home drive' ), 'homeDrive' ), 12 );
2009-10-03 18:27:17 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomePath' )) {
// path to home directory
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Home path' ), 'sambaSamAccount_smbhome' , '' , 'homePath' ), 12 );
2009-10-03 18:27:17 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideProfilePath' )) {
// profile path
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Profile path' ), 'sambaSamAccount_profilePath' , '' , 'profilePath' ), 12 );
2009-10-03 18:27:17 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonScript' )) {
// logon script
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Logon script' ), 'sambaSamAccount_logonScript' , '' , 'scriptPath' ), 12 );
2009-10-03 18:27:17 +00:00
}
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideWorkstations' )) {
// allowed workstations
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Samba workstations' ), 'sambaSamAccount_userWorkstations' , '' , 'workstations' ), 12 );
2009-10-03 18:27:17 +00:00
}
2004-04-11 13:07:24 +00:00
// domains
2010-11-21 19:23:12 +00:00
$sambaDomains = $this -> getDomains ();
2004-04-11 13:07:24 +00:00
$sambaDomainNames = array ();
for ( $i = 0 ; $i < count ( $sambaDomains ); $i ++ ) {
$sambaDomainNames [] = $sambaDomains [ $i ] -> name ;
}
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveSelect ( 'sambaSamAccount_sambaDomainName' , $sambaDomainNames , null , _ ( 'Domain' ), 'domain' ), 12 );
2006-03-19 11:25:57 +00:00
// Windows group
$groups = array ();
2012-11-02 18:05:37 +00:00
foreach ( $this -> groupRids as $key => $value ) {
2010-09-27 16:47:27 +00:00
$groups [ $key ] = $value ;
2006-03-19 11:25:57 +00:00
}
2010-09-27 16:47:27 +00:00
$groups [ " - " ] = " - " ;
2018-05-19 09:14:31 +00:00
$groupSelect = new htmlResponsiveSelect ( 'sambaSamAccount_group' , $groups , array ( '513' ), _ ( 'Windows group' ), 'group' );
2010-09-27 16:47:27 +00:00
$groupSelect -> setHasDescriptiveElements ( true );
2018-05-19 09:14:31 +00:00
$return -> add ( $groupSelect , 12 );
2009-10-03 18:27:17 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideLogonHours' )) {
// logon hours
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveInputField ( _ ( 'Logon hours' ), 'sambaSamAccount_logonHours' , '' , 'logonHoursUpload' ), 12 );
2009-10-03 18:27:17 +00:00
}
2004-04-11 13:07:24 +00:00
}
2004-11-20 12:44:56 +00:00
elseif ( $this -> get_scope () == 'host' ) {
2004-04-11 13:07:24 +00:00
// domains
2010-11-21 19:23:12 +00:00
$sambaDomains = $this -> getDomains ();
2004-04-11 13:07:24 +00:00
$sambaDomainNames = array ();
for ( $i = 0 ; $i < count ( $sambaDomains ); $i ++ ) {
$sambaDomainNames [] = $sambaDomains [ $i ] -> name ;
}
2018-05-19 09:14:31 +00:00
$return -> add ( new htmlResponsiveSelect ( 'sambaSamAccount_sambaDomainName' , $sambaDomainNames , null , _ ( 'Domain' ), 'domain' ), 12 );
2004-04-10 15:23:45 +00:00
}
2004-03-09 12:03:39 +00:00
return $return ;
2003-12-20 21:42:52 +00:00
}
2006-08-14 17:24:27 +00:00
2005-01-29 12:05:16 +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 );
2009-12-20 14:35:42 +00:00
// add extension
2010-06-29 17:18:50 +00:00
if ( isset ( $profile [ 'sambaSamAccount_addExt' ][ 0 ]) && ( $profile [ 'sambaSamAccount_addExt' ][ 0 ] == " true " )) {
2009-12-20 14:35:42 +00:00
if ( ! in_array ( 'sambaSamAccount' , $this -> attributes [ 'objectClass' ])) {
$this -> attributes [ 'objectClass' ][] = 'sambaSamAccount' ;
}
}
2005-01-29 12:05:16 +00:00
// use no password
2010-06-29 17:18:50 +00:00
if ( isset ( $profile [ 'sambaSamAccount_sambaAcctFlagsN' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaAcctFlagsN' ][ 0 ] == " true " )) {
2005-01-29 12:05:16 +00:00
$this -> nopwd = true ;
}
2010-06-29 17:18:50 +00:00
elseif ( isset ( $profile [ 'sambaSamAccount_sambaAcctFlagsN' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaAcctFlagsN' ][ 0 ] == " false " )) {
2005-01-29 12:05:16 +00:00
$this -> nopwd = false ;
}
// password expiration
2010-06-29 17:18:50 +00:00
if ( isset ( $profile [ 'sambaSamAccount_sambaAcctFlagsX' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaAcctFlagsX' ][ 0 ] == " true " )) {
2005-01-29 12:05:16 +00:00
$this -> noexpire = true ;
}
2010-06-29 17:18:50 +00:00
elseif ( isset ( $profile [ 'sambaSamAccount_sambaAcctFlagsX' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaAcctFlagsX' ][ 0 ] == " false " )) {
2005-01-29 12:05:16 +00:00
$this -> noexpire = false ;
}
// use no password
2010-06-29 17:18:50 +00:00
if ( isset ( $profile [ 'sambaSamAccount_sambaAcctFlagsD' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaAcctFlagsD' ][ 0 ] == " true " )) {
2005-01-29 12:05:16 +00:00
$this -> deactivated = true ;
}
2010-06-29 17:18:50 +00:00
elseif ( isset ( $profile [ 'sambaSamAccount_sambaAcctFlagsD' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaAcctFlagsD' ][ 0 ] == " false " )) {
2005-01-29 12:05:16 +00:00
$this -> deactivated = false ;
}
2009-10-03 18:27:17 +00:00
if ( ! $this -> isBooleanConfigOptionSet ( 'sambaSamAccount_hideHomeDrive' )) {
// home drive
2010-06-29 17:18:50 +00:00
if ( isset ( $profile [ 'sambaSamAccount_sambaHomeDrive' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaHomeDrive' ][ 0 ] == " - " )) {
2009-10-03 18:27:17 +00:00
$this -> attributes [ 'sambaHomeDrive' ][ 0 ] = '' ;
}
2010-06-29 17:18:50 +00:00
elseif ( isset ( $profile [ 'sambaSamAccount_sambaHomeDrive' ][ 0 ])) {
2009-10-03 18:27:17 +00:00
$this -> attributes [ 'sambaHomeDrive' ][ 0 ] = $profile [ 'sambaSamAccount_sambaHomeDrive' ][ 0 ];
}
2005-09-20 15:36:58 +00:00
}
2005-10-01 07:26:32 +00:00
// expiration date
if ( isset ( $profile [ 'sambaSamAccount_expire_day' ][ 0 ]) && ( $profile [ 'sambaSamAccount_expire_day' ][ 0 ] != " " )) {
2016-07-20 18:19:26 +00:00
$date = DateTime :: createFromFormat ( 'j.n.Y' , $profile [ 'sambaSamAccount_expire_day' ][ 0 ] . '.' . $profile [ 'sambaSamAccount_expire_mon' ][ 0 ] . '.' . $profile [ 'sambaSamAccount_expire_yea' ][ 0 ], getTimeZone ());
$this -> attributes [ 'sambaKickoffTime' ][ 0 ] = $date -> format ( 'U' );
2005-10-01 07:26:32 +00:00
}
2005-10-13 16:03:51 +00:00
// domain -> change SID
2007-10-10 19:04:39 +00:00
if ( isset ( $this -> attributes [ 'sambaSID' ][ 0 ])) {
2005-10-13 16:03:51 +00:00
if ( isset ( $profile [ 'sambaSamAccount_sambaDomainName' ][ 0 ]) && ( $profile [ 'sambaSamAccount_sambaDomainName' ][ 0 ] != " " )) {
2010-11-21 19:23:12 +00:00
$domains = $this -> getDomains ();
2005-10-13 16:03:51 +00:00
$domSID = '' ;
// find domain SID
for ( $i = 0 ; $i < sizeof ( $domains ); $i ++ ) {
if ( $domains [ $i ] -> name == $profile [ 'sambaSamAccount_sambaDomainName' ][ 0 ]) {
$domSID = $domains [ $i ] -> SID ;
break ;
}
}
// replace domain part of SID
if ( $domSID != '' ) {
$SID = $this -> attributes [ 'sambaSID' ][ 0 ];
$rid = substr ( $SID , strrpos ( $SID , '-' ) + 1 );
$SID = $domSID . '-' . $rid ;
$this -> attributes [ 'sambaSID' ][ 0 ] = $SID ;
}
}
}
2006-03-19 11:25:57 +00:00
// primary group
if ( isset ( $profile [ 'sambaSamAccount_sambaDomainName' ][ 0 ])) {
2010-11-21 19:23:12 +00:00
$domains = $this -> getDomains ();
2006-03-19 11:25:57 +00:00
$domSID = '' ;
// find domain SID
for ( $i = 0 ; $i < sizeof ( $domains ); $i ++ ) {
if ( $domains [ $i ] -> name == $profile [ 'sambaSamAccount_sambaDomainName' ][ 0 ]) {
$domSID = $domains [ $i ] -> SID ;
break ;
}
}
if ( $domSID != '' ) {
// set primary group if selected
if ( isset ( $profile [ 'sambaSamAccount_group' ][ 0 ]) && ( $profile [ 'sambaSamAccount_group' ][ 0 ] != " - " )) {
$this -> attributes [ 'sambaPrimaryGroupSID' ][ 0 ] = $domSID . " - " . $profile [ 'sambaSamAccount_group' ][ 0 ];
}
}
2008-12-15 22:27:36 +00:00
}
2005-01-29 12:05:16 +00:00
}
2016-07-09 06:26:05 +00:00
/**
* Returns a list of configuration options .
*
* Calling this method does not require the existence of an enclosing { @ link accountContainer } .< br >
* < br >
* The field names are used as keywords to load and save settings .
* We recommend to use the module name as prefix for them ( e . g . posixAccount_homeDirectory ) to avoid naming conflicts .
*
* @ param array $scopes account types ( user , group , host )
* @ param array $allScopes list of all active account modules and their scopes ( module => array ( scopes ))
* @ return mixed htmlElement or array of htmlElement
*
* @ see baseModule :: get_metaData ()
* @ see htmlElement
*/
public function get_configOptions ( $scopes , $allScopes ) {
$return = parent :: get_configOptions ( $scopes , $allScopes );
if ( ! in_array ( 'user' , $scopes )) {
return $return ;
}
2017-12-02 17:07:33 +00:00
$configContainer = new htmlResponsiveRow ();
2016-07-09 06:26:05 +00:00
// password history
$historyOptions = array (
_ ( 'yes - ordered ascending' ) => 'yes_deleteLast' ,
_ ( 'yes - ordered descending' ) => 'yes_deleteFirst' ,
_ ( 'no' ) => 'no'
);
2017-12-02 17:07:33 +00:00
$historySelect = new htmlResponsiveSelect ( 'sambaSamAccount_history' , $historyOptions , array ( 'yes_deleteLast' ), _ ( " Password history " ), 'history' );
2016-07-09 06:26:05 +00:00
$historySelect -> setHasDescriptiveElements ( true );
2017-12-02 17:07:33 +00:00
$configContainer -> add ( $historySelect , 12 );
2016-07-09 06:26:05 +00:00
// disable LM passwords
$yesNo = array ( _ ( 'yes' ) => 'yes' , _ ( 'no' ) => 'no' );
2017-12-02 17:07:33 +00:00
$lmYesNoSelect = new htmlResponsiveSelect ( 'sambaSamAccount_lmHash' , $yesNo , array ( 'yes' ), _ ( " Disable LM hashes " ), 'lmHash' );
2016-07-09 06:26:05 +00:00
$lmYesNoSelect -> setHasDescriptiveElements ( true );
2017-12-02 17:07:33 +00:00
$configContainer -> add ( $lmYesNoSelect , 12 );
2016-07-09 06:26:05 +00:00
// hidden options
2017-12-02 17:07:33 +00:00
$configContainer -> addVerticalSpacer ( '1rem' );
2016-07-09 06:26:05 +00:00
$configHiddenLabelGroup = new htmlGroup ();
$configHiddenLabelGroup -> addElement ( new htmlOutputText ( _ ( 'Hidden options' ) . ' ' ));
$configHiddenLabelGroup -> addElement ( new htmlHelpLink ( 'hiddenOptions' ));
2017-12-02 17:07:33 +00:00
$configContainer -> add ( $configHiddenLabelGroup , 12 );
$configContainer -> addVerticalSpacer ( '0.5rem' );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideHomeDrive' , false , _ ( 'Home drive' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideHomePath' , false , _ ( 'Home path' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideProfilePath' , false , _ ( 'Profile path' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideLogonScript' , false , _ ( 'Logon script' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideSambaPwdLastSet' , false , _ ( 'Last password change' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideWorkstations' , false , _ ( 'Samba workstations' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideLogonHours' , false , _ ( 'Logon hours' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlResponsiveInputCheckbox ( 'sambaSamAccount_hideTerminalServer' , false , _ ( 'Terminal server options' ), null , true ), 12 , 4 );
$configContainer -> add ( new htmlOutputText ( '' ), 12 , 4 );
2016-07-09 06:26:05 +00:00
$return [] = $configContainer ;
return $return ;
}
2005-10-09 18:05:32 +00:00
/**
2017-02-19 08:14:11 +00:00
* { @ inheritDoc }
* @ see baseModule :: get_pdfEntries ()
2015-01-07 17:16:35 +00:00
*/
2017-04-01 07:57:03 +00:00
function get_pdfEntries ( $pdfKeys , $typeId ) {
2007-02-13 17:51:09 +00:00
$return = array ();
2013-05-09 17:26:56 +00:00
$this -> addSimplePDFField ( $return , 'displayName' , _ ( 'Display name' ));
$this -> addSimplePDFField ( $return , 'sambaHomePath' , _ ( 'Home path' ));
$this -> addSimplePDFField ( $return , 'sambaHomeDrive' , _ ( 'Home drive' ));
$this -> addSimplePDFField ( $return , 'sambaLogonScript' , _ ( 'Logon script' ));
$this -> addSimplePDFField ( $return , 'sambaProfilePath' , _ ( 'Profile path' ));
$this -> addSimplePDFField ( $return , 'sambaUserWorkstations' , _ ( 'Samba workstations' ));
$this -> addSimplePDFField ( $return , 'sambaDomainName' , _ ( 'Domain' ));
$this -> addSimplePDFField ( $return , 'sambaPrimaryGroupSID' , _ ( 'Windows group' ));
2017-04-18 16:28:10 +00:00
$this -> addPDFKeyValue ( $return , 'sambaKickoffTime' , _ ( 'Account expiration date' ), $this -> formatAccountExpirationDate ());
2007-10-22 19:05:25 +00:00
// terminal server options
if ( isset ( $this -> attributes [ 'sambaMungedDial' ][ 0 ])) {
$mDial = new sambaMungedDial ();
$mDial -> load ( $this -> attributes [ 'sambaMungedDial' ][ 0 ]);
$tsAllowLogin = _ ( 'yes' );
if ( ! $mDial -> getTsLogin ()) {
$tsAllowLogin = _ ( 'no' );
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsAllowLogin' , _ ( 'Allow terminal server login' ), $tsAllowLogin );
$this -> addPDFKeyValue ( $return , 'tsHomeDir' , _ ( 'Home directory' ) . ' (TS)' , $mDial -> ctx [ 'CtxWFHomeDir' ]);
$this -> addPDFKeyValue ( $return , 'tsHomeDrive' , _ ( 'Home drive' ) . ' (TS)' , $mDial -> ctx [ 'CtxWFHomeDirDrive' ]);
$this -> addPDFKeyValue ( $return , 'tsProfilePath' , _ ( 'Profile path' ) . ' (TS)' , $mDial -> ctx [ 'CtxWFProfilePath' ]);
2007-10-22 19:05:25 +00:00
$tsInherit = _ ( 'yes' );
if ( ! $mDial -> getInheritMode ()) {
$tsInherit = _ ( 'no' );
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsInherit' , _ ( 'Inherit client startup configuration' ) . ' (TS)' , $tsInherit );
$this -> addPDFKeyValue ( $return , 'tsInitialProgram' , _ ( 'Initial program' ) . ' (TS)' , $mDial -> ctx [ 'CtxInitialProgram' ]);
$this -> addPDFKeyValue ( $return , 'tsWorkDirectory' , _ ( 'Working directory' ) . ' (TS)' , $mDial -> ctx [ 'CtxWorkDirectory' ]);
$this -> addPDFKeyValue ( $return , 'tsConnectionLimit' , _ ( 'Connection time limit' ) . ' (TS)' , $mDial -> ctx [ 'CtxMaxConnectionTime' ]);
$this -> addPDFKeyValue ( $return , 'tsDisconnectionLimit' , _ ( 'Disconnection time limit' ) . ' (TS)' , $mDial -> ctx [ 'CtxMaxDisconnectionTime' ]);
$this -> addPDFKeyValue ( $return , 'tsIdleLimit' , _ ( 'Idle time limit' ) . ' (TS)' , $mDial -> ctx [ 'CtxMaxIdleTime' ]);
2007-10-22 19:05:25 +00:00
$tsConnectDrives = _ ( 'yes' );
if ( ! $mDial -> getConnectClientDrives ()) {
$tsConnectDrives = _ ( 'no' );
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsConnectDrives' , _ ( 'Connect client drives' ) . ' (TS)' , $tsConnectDrives );
2007-10-22 19:05:25 +00:00
$tsConnectPrinters = _ ( 'yes' );
if ( ! $mDial -> getConnectClientPrinters ()) {
$tsConnectPrinters = _ ( 'no' );
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsConnectPrinters' , _ ( 'Connect client printers' ) . ' (TS)' , $tsConnectPrinters );
2007-10-22 19:05:25 +00:00
$tsClientPrinterDefault = _ ( 'yes' );
if ( ! $mDial -> getDefaultPrinter ()) {
$tsClientPrinterDefault = _ ( 'no' );
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsClientPrinterDefault' , _ ( 'Client printer is default' ) . ' (TS)' , $tsClientPrinterDefault );
2007-10-22 19:05:25 +00:00
$shadowOptions = array (
'0' => _ ( " disabled " ),
'1' => _ ( " input on, notify on " ),
'2' => _ ( " input on, notify off " ),
'3' => _ ( " input off, notify on " ),
2007-10-30 13:43:00 +00:00
'4' => _ ( " input off, notify off " ));
2007-10-22 19:05:25 +00:00
$tsShadowing = '' ;
if (( $mDial -> getShadow () != null ) && is_numeric ( $mDial -> getShadow ())) {
$tsShadowing = $shadowOptions [ $mDial -> getShadow ()];
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsShadowing' , _ ( 'Shadowing' ) . ' (TS)' , $tsShadowing );
2007-10-22 19:05:25 +00:00
$brokenConnOptions = array (
'0' => _ ( " disconnect " ),
'1' => _ ( " reset " ));
$tsBrokenConn = '' ;
if (( $mDial -> getBrokenConn () != null ) && is_numeric ( $mDial -> getBrokenConn ())) {
$tsBrokenConn = $brokenConnOptions [ $mDial -> getBrokenConn ()];
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsBrokenConn' , _ ( 'On broken or timed out connection' ) . ' (TS)' , $tsBrokenConn );
2007-10-22 19:05:25 +00:00
$reconnectOptions = array (
'0' => _ ( " from any client " ),
'1' => _ ( " from previous client only " ));
$tsReconnect = '' ;
if (( $mDial -> getReConn () != null ) && is_numeric ( $mDial -> getReConn ())) {
$tsReconnect = $reconnectOptions [ $mDial -> getReConn ()];
}
2015-03-13 17:15:45 +00:00
$this -> addPDFKeyValue ( $return , 'tsReconnect' , _ ( 'Reconnect if disconnected' ) . ' (TS)' , $tsReconnect );
2007-10-22 19:05:25 +00:00
}
2007-02-13 17:51:09 +00:00
return $return ;
2004-05-24 21:39:57 +00:00
}
2004-03-14 17:33:05 +00:00
2004-12-01 12:59:14 +00:00
/**
2017-05-20 09:46:49 +00:00
* { @ inheritDoc }
* @ see baseModule :: build_uploadAccounts ()
*/
function build_uploadAccounts ( $rawAccounts , $ids , & $partialAccounts , $selectedModules , & $type ) {
2006-05-18 08:30:22 +00:00
$errors = array ();
2004-12-01 12:59:14 +00:00
// get list of Samba 3 domains
2010-11-21 19:23:12 +00:00
$domains = $this -> getDomains ();
2004-12-01 12:59:14 +00:00
// get list of Unix groups and their sambaSID + gidNumber
2010-11-21 14:32:42 +00:00
$groupList = searchLDAPByFilter ( 'objectClass=posixGroup' , array ( 'cn' , 'sambaSID' , 'gidNumber' ), array ( 'group' ));
2004-12-01 12:59:14 +00:00
$groups_cn = array ();
2010-11-21 14:32:42 +00:00
for ( $i = 0 ; $i < sizeof ( $groupList ); $i ++ ) {
if ( isset ( $groupList [ $i ][ 'sambasid' ][ 0 ])) {
$groups_cn [ $groupList [ $i ][ 'cn' ][ 0 ]][ 'SID' ] = $groupList [ $i ][ 'sambasid' ][ 0 ];
2005-05-05 13:53:27 +00:00
}
2010-11-21 14:32:42 +00:00
if ( isset ( $groupList [ $i ][ 'gidnumber' ][ 0 ])) {
$groups_cn [ $groupList [ $i ][ 'cn' ][ 0 ]][ 'gid' ] = $groupList [ $i ][ 'gidnumber' ][ 0 ];
2005-05-05 13:53:27 +00:00
}
2004-12-01 12:59:14 +00:00
}
if ( $this -> get_scope () == 'user' ) {
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
if ( ! in_array ( " sambaSamAccount " , $partialAccounts [ $i ][ 'objectClass' ])) $partialAccounts [ $i ][ 'objectClass' ][] = " sambaSamAccount " ;
// displayName
2014-04-18 18:29:51 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'sambaSamAccount_displayName' , 'displayName' ,
'realname' , $this -> messages [ 'displayName' ][ 0 ], $errors );
2004-12-01 12:59:14 +00:00
// password
2006-02-25 09:30:17 +00:00
$partialAccounts [ $i ][ 'sambaPwdLastSet' ] = time ();
2004-12-01 12:59:14 +00:00
if ( ! get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_password' ]], 'password' )) {
$errMsg = $this -> messages [ 'sambaLMPassword' ][ 2 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
// use Unix password
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_pwdUnix' ]] == " " ) { // default: use Unix
2009-05-03 15:16:15 +00:00
if ( isset ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ]) && ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ] == 'no' )) {
$partialAccounts [ $i ][ 'sambaLMPassword' ] = lmPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
}
2005-10-04 15:17:24 +00:00
$partialAccounts [ $i ][ 'sambaNTPassword' ] = ntPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
2004-12-01 12:59:14 +00:00
}
elseif ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_pwdUnix' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_pwdUnix' ]] == 'true' ) { // use Unix
2009-05-03 15:16:15 +00:00
if ( isset ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ]) && ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ] == 'no' )) {
$partialAccounts [ $i ][ 'sambaLMPassword' ] = lmPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
}
2005-10-04 15:17:24 +00:00
$partialAccounts [ $i ][ 'sambaNTPassword' ] = ntPassword ( $rawAccounts [ $i ][ $ids [ 'posixAccount_password' ]]);
2004-12-01 12:59:14 +00:00
}
else { // use given password
2009-05-03 15:16:15 +00:00
if ( isset ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ]) && ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ] == 'no' )) {
$partialAccounts [ $i ][ 'sambaLMPassword' ] = lmPassword ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_password' ]]);
}
2004-12-01 12:59:14 +00:00
$partialAccounts [ $i ][ 'sambaNTPassword' ] = ntPassword ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_password' ]]);
}
}
else {
$errMsg = $this -> messages [ 'pwdUnix' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
// use no password
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_noPassword' ]] != " " ) {
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_noPassword' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_noPassword' ]] == 'true' ) {
$partialAccounts [ $i ][ 'sambaLMPassword' ] = 'NO PASSWORD*****' ;
$partialAccounts [ $i ][ 'sambaNTPassword' ] = 'NO PASSWORD*****' ;
}
}
else {
$errMsg = $this -> messages [ 'noPassword' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
}
// account flags
$flag_expire = false ;
$flag_deactivated = false ;
// password does not expire
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_noExpire' ]] != " " ) {
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_noExpire' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_noExpire' ]] == 'false' ) {
$flag_expire = true ;
}
}
else {
$errMsg = $this -> messages [ 'noExpire' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
}
// account is deactivated
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_deactivated' ]] != " " ) {
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_deactivated' ]], array ( 'true' , 'false' ))) {
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_deactivated' ]] == 'true' ) {
$flag_deactivated = true ;
}
}
else {
$errMsg = $this -> messages [ 'deactivated' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +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 ][ 'sambaAcctFlags' ] = $flags ;
2005-10-01 07:26:32 +00:00
// expiration date
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_expireDate' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_expireDate' ]], 'date' )) {
$parts = explode ( " - " , $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_expireDate' ]]);
2016-07-20 18:19:26 +00:00
$date = DateTime :: createFromFormat ( 'j.n.Y' , $parts [ 0 ] . '.' . $parts [ 1 ] . '.' . $parts [ 2 ], getTimeZone ());
$partialAccounts [ $i ][ 'sambaKickoffTime' ] = $date -> format ( 'U' );
2005-10-01 07:26:32 +00:00
}
else {
$errMsg = $this -> messages [ 'expireDate' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
}
// home drive
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_homeDrive' ]] != " " ) {
2009-08-13 18:57:26 +00:00
if ( preg_match ( " /[d-z]:/i " , $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_homeDrive' ]])) {
2004-12-01 12:59:14 +00:00
$partialAccounts [ $i ][ 'sambaHomeDrive' ] = $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_homeDrive' ]];
}
else {
$errMsg = $this -> messages [ 'homeDrive' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
}
// home path
2014-04-18 18:29:51 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'sambaSamAccount_homePath' , 'sambaHomePath' ,
'UNC' , $this -> messages [ 'homePath' ][ 2 ], $errors );
2004-12-01 12:59:14 +00:00
// profile path
2014-04-18 18:29:51 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'sambaSamAccount_profilePath' , 'sambaProfilePath' ,
'UNC' , $this -> messages [ 'profilePath' ][ 2 ], $errors );
2004-12-01 12:59:14 +00:00
// logon script
2014-04-18 18:29:51 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'sambaSamAccount_logonScript' , 'sambaLogonScript' ,
'logonscript' , $this -> messages [ 'logonScript' ][ 2 ], $errors );
2004-12-01 12:59:14 +00:00
// workstations
2014-04-18 18:29:51 +00:00
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'sambaSamAccount_workstations' , 'sambaUserWorkstations' ,
'workstations' , $this -> messages [ 'workstations' ][ 1 ], $errors );
2004-12-01 12:59:14 +00:00
// domain
$domIndex = - 1 ;
for ( $d = 0 ; $d < sizeof ( $domains ); $d ++ ) {
if ( $domains [ $d ] -> name == $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_domain' ]]) {
$domIndex = $d ;
break ;
}
}
if ( $domIndex > - 1 ) {
$partialAccounts [ $i ][ 'sambaDomainName' ] = $domains [ $domIndex ] -> name ;
$partialAccounts [ $i ][ 'sambaSID' ] = $domains [ $domIndex ] -> SID ;
}
else {
$errMsg = $this -> messages [ 'domain' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
// group
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]], 'groupname' )
&& ( isset ( $groups_cn [ $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]]]))) {
if ( isset ( $groups_cn [ $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]]][ 'SID' ])) {
$partialAccounts [ $i ][ 'sambaPrimaryGroupSID' ] = $groups_cn [ $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]]][ 'SID' ];
}
else {
2006-08-14 17:24:27 +00:00
$partialAccounts [ $i ][ 'sambaPrimaryGroupSID' ] = $domains [ $domIndex ] -> SID . '-' .
( $groups_cn [ $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]]][ 'gid' ] * 2 +
2004-12-01 12:59:14 +00:00
$domains [ $domIndex ] -> RIDbase + 1 );
}
}
2012-11-02 18:05:37 +00:00
elseif ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]], array_keys ( $this -> groupRids ))) {
$partialAccounts [ $i ][ 'sambaPrimaryGroupSID' ] = $domains [ $domIndex ] -> SID . '-' . $this -> groupRids [ $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_group' ]]];
2004-12-01 12:59:14 +00:00
}
else {
$errMsg = $this -> messages [ 'group' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
}
else {
// default domain users
2012-11-02 18:05:37 +00:00
$partialAccounts [ $i ][ 'sambaPrimaryGroupSID' ] = $domains [ $domIndex ] -> SID . '-' . $this -> groupRids [ _ ( 'Domain users' )];
2004-12-01 12:59:14 +00:00
}
// special user
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]] != " " ) {
2012-11-02 18:05:37 +00:00
if ( in_array ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]], array_keys ( $this -> userRids ))) {
$partialAccounts [ $i ][ 'sambaSID' ] .= '-' . $this -> userRids [ $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]]];
2004-12-01 12:59:14 +00:00
}
elseif ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]], 'digit' )) {
$partialAccounts [ $i ][ 'sambaSID' ] .= '-' . $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]];
}
else {
$errMsg = $this -> messages [ 'rid' ][ 2 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-01 12:59:14 +00:00
}
}
else {
// default RID uid*2 + RIDBase
$partialAccounts [ $i ][ 'sambaSID' ] .= '-' . ( $partialAccounts [ $i ][ 'uidNumber' ] * 2 + $domains [ $domIndex ] -> RIDbase );
}
// logon hours
2014-04-18 18:29:51 +00:00
$partialAccounts [ $i ][ 'sambaLogonHours' ] = " FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF " ;
$this -> mapSimpleUploadField ( $rawAccounts , $ids , $partialAccounts , $i , 'sambaSamAccount_logonHours' , 'sambaLogonHours' ,
'sambaLogonHours' , $this -> messages [ 'logonHours' ][ 1 ], $errors );
2004-12-01 12:59:14 +00:00
}
}
2004-12-09 21:40:39 +00:00
else { // hosts
for ( $i = 0 ; $i < sizeof ( $rawAccounts ); $i ++ ) {
if ( ! in_array ( " sambaSamAccount " , $partialAccounts [ $i ][ 'objectClass' ])) $partialAccounts [ $i ][ 'objectClass' ][] = " sambaSamAccount " ;
// domain
$domIndex = - 1 ;
for ( $d = 0 ; $d < sizeof ( $domains ); $d ++ ) {
if ( $domains [ $d ] -> name == $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_domain' ]]) {
$domIndex = $d ;
break ;
}
}
if ( $domIndex > - 1 ) {
$partialAccounts [ $i ][ 'sambaDomainName' ] = $domains [ $domIndex ] -> name ;
$partialAccounts [ $i ][ 'sambaSID' ] = $domains [ $domIndex ] -> SID ;
$partialAccounts [ $i ][ 'sambaPrimaryGroupSID' ] = $domains [ $domIndex ] -> SID . " - 515 " ;
}
else {
$errMsg = $this -> messages [ 'domain' ][ 0 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-09 21:40:39 +00:00
}
// RID
if ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]] != " " ) {
if ( get_preg ( $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]], 'digit' )) {
$partialAccounts [ $i ][ 'sambaSID' ] .= '-' . $rawAccounts [ $i ][ $ids [ 'sambaSamAccount_rid' ]];
}
else {
$errMsg = $this -> messages [ 'rid' ][ 3 ];
array_push ( $errMsg , array ( $i ));
2006-05-18 08:30:22 +00:00
$errors [] = $errMsg ;
2004-12-09 21:40:39 +00:00
}
}
else {
// default RID uid*2 + RIDBase
$partialAccounts [ $i ][ 'sambaSID' ] .= '-' . ( $partialAccounts [ $i ][ 'uidNumber' ] * 2 + $domains [ $domIndex ] -> RIDbase );
}
// passwords ( = host name)
2008-12-14 10:20:05 +00:00
$partialAccounts [ $i ][ 'sambaPwdLastSet' ] = time ();
2009-05-03 15:16:15 +00:00
if ( isset ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ]) && ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ] == 'no' )) {
2018-04-30 17:29:31 +00:00
$partialAccounts [ $i ][ 'sambaLMPassword' ] = lmPassword ( substr ( $partialAccounts [ $i ][ 'uid' ], 0 , strlen ( $partialAccounts [ $i ][ 'uid' ]) - 1 ));
2009-05-03 15:16:15 +00:00
}
2018-04-30 17:29:31 +00:00
$partialAccounts [ $i ][ 'sambaNTPassword' ] = ntPassword ( substr ( $partialAccounts [ $i ][ 'uid' ], 0 , strlen ( $partialAccounts [ $i ][ 'uid' ]) - 1 ));
2004-12-09 21:40:39 +00:00
// flags
$partialAccounts [ $i ][ 'sambaAcctFlags' ] = " [W ] " ;
}
}
2006-05-18 08:30:22 +00:00
return $errors ;
2004-12-01 12:59:14 +00:00
}
2016-07-09 07:31:55 +00:00
/**
2017-12-17 11:03:43 +00:00
* { @ inheritDoc }
* @ see baseModule :: getSelfServiceSettings ()
2016-07-09 07:31:55 +00:00
*/
public function getSelfServiceSettings ( $profile ) {
2017-12-17 11:03:43 +00:00
$selfServiceContainer = new htmlResponsiveRow ();
2016-07-09 07:31:55 +00:00
// domain suffix
2017-12-17 11:03:43 +00:00
$selfServiceDomainSuffix = new htmlResponsiveInputField ( _ ( 'Domain suffix' ), 'sambaSamAccount_domainSuffix' , null , array ( 'domainSuffix' , get_class ( $this )));
$selfServiceContainer -> add ( $selfServiceDomainSuffix , 12 );
2016-07-09 07:31:55 +00:00
// password history
$historyOptions = array (
_ ( 'yes - ordered ascending' ) => 'yes_deleteLast' ,
_ ( 'yes - ordered descending' ) => 'yes_deleteFirst' ,
_ ( 'no' ) => 'no'
);
2017-12-17 11:03:43 +00:00
$historySelect = new htmlResponsiveSelect ( 'sambaSamAccount_history' , $historyOptions , array ( 'yes_deleteLast' ), _ ( " Password history " ), array ( 'history' , get_class ( $this )));
2016-07-09 07:31:55 +00:00
$historySelect -> setHasDescriptiveElements ( true );
2017-12-17 11:03:43 +00:00
$selfServiceContainer -> add ( $historySelect , 12 );
2016-07-09 07:31:55 +00:00
return $selfServiceContainer ;
}
2012-08-17 16:28:42 +00:00
/**
* Returns the meta HTML code for each input field .
* format : array ( < field1 > => array ( < META HTML > ), ... )
* It is not possible to display help links .
*
* @ param array $fields list of active fields
* @ param array $attributes attributes of LDAP account
* @ param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
2012-08-18 15:55:43 +00:00
* @ param array $readOnlyFields list of read - only fields
2015-08-06 19:20:54 +00:00
* @ return array list of meta HTML elements ( field name => htmlResponsiveRow )
2012-08-17 16:28:42 +00:00
*/
2012-08-18 15:55:43 +00:00
function getSelfServiceOptions ( $fields , $attributes , $passwordChangeOnly , $readOnlyFields ) {
2012-08-17 16:28:42 +00:00
$return = array ();
if ( $passwordChangeOnly ) {
return $return ; // no input fields as long no LDAP content can be read
}
if ( ! isset ( $attributes [ 'objectClass' ]) || ! in_array_ignore_case ( 'sambaSamAccount' , $attributes [ 'objectClass' ])) {
return $return ;
}
if ( in_array ( 'password' , $fields )) {
2015-08-06 19:20:54 +00:00
$group = new htmlGroup ();
$pwd1 = new htmlResponsiveInputField ( $this -> getSelfServiceLabel ( 'password' , _ ( 'New password' )), 'sambaSamAccount_password' );
2014-05-25 17:29:19 +00:00
$pwd1 -> setIsPassword ( true , true );
2015-08-06 19:20:54 +00:00
$group -> addElement ( $pwd1 );
$pwd2 = new htmlResponsiveInputField ( _ ( 'Reenter password' ), 'sambaSamAccount_password2' );
2012-08-17 16:28:42 +00:00
$pwd2 -> setIsPassword ( true );
2014-05-25 14:37:05 +00:00
$pwd2 -> setSameValueFieldID ( 'sambaSamAccount_password' );
2015-08-06 19:20:54 +00:00
$group -> addElement ( $pwd2 );
$row = new htmlResponsiveRow ();
$row -> add ( $group , 12 );
$return [ 'password' ] = $row ;
2012-08-17 16:28:42 +00:00
}
2013-09-28 11:44:41 +00:00
if ( in_array ( 'sambaPwdLastSet' , $fields )) {
$sambaPwdLastSet = '' ;
if ( isset ( $attributes [ 'sambaPwdLastSet' ][ 0 ])) {
2015-11-07 09:14:48 +00:00
$time = new DateTime ( '@' . $attributes [ 'sambaPwdLastSet' ][ 0 ], new DateTimeZone ( 'UTC' ));
$time -> setTimezone ( getTimeZone ());
2015-08-23 17:56:27 +00:00
$sambaPwdLastSet = $time -> format ( 'd.m.Y H:i' );
2013-09-28 11:44:41 +00:00
}
2015-08-06 19:20:54 +00:00
$row = new htmlResponsiveRow ();
2015-08-09 07:57:56 +00:00
$row -> addLabel ( new htmlOutputText ( $this -> getSelfServiceLabel ( 'sambaPwdLastSet' , _ ( 'Last password change' ))));
$row -> addField ( new htmlOutputText ( $sambaPwdLastSet ));
2015-08-06 19:20:54 +00:00
$return [ 'sambaPwdLastSet' ] = $row ;
2013-09-28 11:44:41 +00:00
}
2012-08-17 16:28:42 +00:00
return $return ;
}
2006-10-05 17:51:17 +00:00
/**
2011-02-26 13:14:10 +00:00
* Checks if all input values are correct and returns the LDAP attributes which should be changed .
* < br > Return values :
* < br > messages : array of parameters to create status messages
* < br > add : array of attributes to add
* < br > del : array of attributes to remove
* < br > mod : array of attributes to modify
* < br > info : array of values with informational value ( e . g . to be used later by pre / postModify actions )
2015-08-06 19:20:54 +00:00
*
2011-02-26 13:14:10 +00:00
* Calling this method does not require the existence of an enclosing { @ link accountContainer } .
2006-10-05 17:51:17 +00:00
*
* @ param string $fields input fields
* @ param array $attributes LDAP attributes
2012-02-08 17:55:00 +00:00
* @ param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
2012-08-18 15:55:43 +00:00
* @ param array $readOnlyFields list of read - only fields
2011-02-26 13:14:10 +00:00
* @ return array messages and attributes ( array ( 'messages' => array (), 'add' => array ( 'mail' => array ( 'test@test.com' )), 'del' => array (), 'mod' => array (), 'info' => array ()))
2006-10-05 17:51:17 +00:00
*/
2012-08-18 15:55:43 +00:00
function checkSelfServiceOptions ( $fields , $attributes , $passwordChangeOnly , $readOnlyFields ) {
2011-02-26 13:14:10 +00:00
$return = array ( 'messages' => array (), 'add' => array (), 'del' => array (), 'mod' => array (), 'info' => array ());
2012-02-08 17:55:00 +00:00
if ( ! isset ( $attributes [ 'objectClass' ]) || ! in_array_ignore_case ( 'sambaSamAccount' , $attributes [ 'objectClass' ])) {
2008-12-14 10:20:05 +00:00
return $return ;
}
2012-08-17 16:28:42 +00:00
if ( in_array ( 'password' , $fields )) {
if ( isset ( $_POST [ 'sambaSamAccount_password' ]) && ( $_POST [ 'sambaSamAccount_password' ] != '' )) {
if ( $_POST [ 'sambaSamAccount_password' ] != $_POST [ 'sambaSamAccount_password2' ]) {
$return [ 'messages' ][] = $this -> messages [ 'sambaLMPassword' ][ 0 ];
}
else {
if ( ! get_preg ( $_POST [ 'sambaSamAccount_password' ], 'password' )) {
$return [ 'messages' ][] = $this -> messages [ 'sambaLMPassword' ][ 1 ];
}
else {
2014-04-17 19:26:08 +00:00
$userName = empty ( $attributes [ 'uid' ][ 0 ]) ? null : $attributes [ 'uid' ][ 0 ];
$additionalAttrs = array ();
if ( ! empty ( $attributes [ 'sn' ][ 0 ])) {
$additionalAttrs [] = $attributes [ 'sn' ][ 0 ];
}
if ( ! empty ( $attributes [ 'givenName' ][ 0 ])) {
$additionalAttrs [] = $attributes [ 'givenName' ][ 0 ];
}
$pwdPolicyResult = checkPasswordStrength ( $_POST [ 'sambaSamAccount_password' ], $userName , $additionalAttrs );
2012-08-17 16:28:42 +00:00
if ( $pwdPolicyResult === true ) {
$return [ 'mod' ][ 'sambaNTPassword' ][ 0 ] = ntPassword ( $_POST [ 'sambaSamAccount_password' ]);
2016-05-26 17:41:10 +00:00
$return [ 'info' ][ 'sambaUserPasswordClearText' ][ 0 ] = $_POST [ 'sambaSamAccount_password' ];
$this -> doSelfServicePasswordHistoryAndMinAge ( $attributes , $return );
2012-08-17 16:28:42 +00:00
if ( array_key_exists ( 'sambaLMPassword' , $attributes )) {
$return [ 'mod' ][ 'sambaLMPassword' ][ 0 ] = lmPassword ( $_POST [ 'sambaSamAccount_password' ]);
}
if ( array_key_exists ( 'sambaPwdLastSet' , $attributes )) {
$return [ 'mod' ][ 'sambaPwdLastSet' ][ 0 ] = time ();
}
}
else {
$return [ 'messages' ][] = array ( 'ERROR' , $pwdPolicyResult );
}
}
}
}
}
2006-10-05 17:51:17 +00:00
if ( isset ( $_POST [ 'posixAccount_password' ]) && ( $_POST [ 'posixAccount_password' ] != '' )) {
if ( $_POST [ 'posixAccount_password' ] != $_POST [ 'posixAccount_password2' ]) {
2008-12-14 10:20:05 +00:00
return $return ;
2006-10-05 17:51:17 +00:00
}
else {
if ( ! get_preg ( $_POST [ 'posixAccount_password' ], 'password' )) {
2008-12-14 10:20:05 +00:00
return $return ;
2006-10-05 17:51:17 +00:00
}
else {
2008-12-14 10:20:05 +00:00
$setPassword = false ;
2006-10-05 17:51:17 +00:00
// sync password
if ( in_array ( 'syncNTPassword' , $fields )) {
$return [ 'mod' ][ 'sambaNTPassword' ][ 0 ] = ntPassword ( $_POST [ 'posixAccount_password' ]);
2008-12-14 10:20:05 +00:00
$setPassword = true ;
2006-10-05 17:51:17 +00:00
}
if ( in_array ( 'syncLMPassword' , $fields )) {
$return [ 'mod' ][ 'sambaLMPassword' ][ 0 ] = lmPassword ( $_POST [ 'posixAccount_password' ]);
2008-12-14 10:20:05 +00:00
$setPassword = true ;
}
if ( $setPassword ) {
2016-05-26 17:41:10 +00:00
$return [ 'info' ][ 'sambaUserPasswordClearText' ][ 0 ] = $_POST [ 'posixAccount_password' ];
$this -> doSelfServicePasswordHistoryAndMinAge ( $attributes , $return );
2008-12-14 10:20:05 +00:00
if ( in_array ( 'syncSambaPwdLastSet' , $fields )) {
$return [ 'mod' ][ 'sambaPwdLastSet' ][ 0 ] = time ();
}
}
2006-10-05 17:51:17 +00:00
}
}
}
return $return ;
}
2016-05-26 17:41:10 +00:00
/**
* Checks password history and password minimum age and updates history .
*
* @ param array $attributes LDAP attributes of current account
* @ param array $return return object of checkSelfServiceOptions ()
*/
private function doSelfServicePasswordHistoryAndMinAge ( $attributes , & $return ) {
if ( ! empty ( $this -> selfServiceSettings -> moduleSettings [ 'sambaSamAccount_domainSuffix' ][ 0 ])) {
$sambaDomain = $this -> getUserDomain ( $attributes , $_SESSION [ 'ldapHandle' ], $this -> selfServiceSettings -> moduleSettings [ 'sambaSamAccount_domainSuffix' ][ 0 ]);
2016-05-26 18:08:08 +00:00
if ( $sambaDomain == null ) {
return ;
}
if ( ! empty ( $sambaDomain -> pwdHistoryLength )
2016-05-26 17:41:10 +00:00
&& is_numeric ( $sambaDomain -> pwdHistoryLength )
&& ( $sambaDomain -> pwdHistoryLength > 0 )) {
if ( sambaSamAccount :: oldPasswordUsed ( $return [ 'info' ][ 'sambaUserPasswordClearText' ][ 0 ], $attributes , $sambaDomain )) {
$return [ 'messages' ][] = array ( 'ERROR' , _ ( 'You are reusing an old password. Please choose a different password.' ));
}
else {
// update password history
2016-07-09 07:31:55 +00:00
if ( sambaSamAccount :: isPasswordHistoryEnabled ( $this -> selfServiceSettings -> moduleSettings )) {
2018-07-07 12:04:43 +00:00
$sambaPasswordHistory = empty ( $attributes [ 'sambaPasswordHistory' ]) ? array () : $attributes [ 'sambaPasswordHistory' ];
2016-07-09 07:31:55 +00:00
while ( sizeof ( $sambaPasswordHistory ) > ( $sambaDomain -> pwdHistoryLength - 1 )) {
if ( empty ( $this -> selfServiceSettings -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ]) || ( $this -> selfServiceSettings -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ] == 'yes_deleteLast' )) {
array_pop ( $sambaPasswordHistory );
}
else {
array_shift ( $sambaPasswordHistory );
}
}
if ( empty ( $this -> selfServiceSettings -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ]) || ( $this -> selfServiceSettings -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ] == 'yes_deleteLast' )) {
array_unshift ( $sambaPasswordHistory , sambaSamAccount :: createHistoryEntry ( $return [ 'info' ][ 'sambaUserPasswordClearText' ][ 0 ]));
}
else {
$sambaPasswordHistory [] = sambaSamAccount :: createHistoryEntry ( $return [ 'info' ][ 'sambaUserPasswordClearText' ][ 0 ]);
}
$sambaPasswordHistory = array_values ( $sambaPasswordHistory );
if ( empty ( $attributes [ 'sambaPasswordHistory' ])) {
$return [ 'add' ][ 'sambaPasswordHistory' ] = $sambaPasswordHistory ;
}
else {
$return [ 'mod' ][ 'sambaPasswordHistory' ] = $sambaPasswordHistory ;
}
2016-05-26 17:41:10 +00:00
}
}
}
2016-05-26 18:08:08 +00:00
// check min age
if ( ! empty ( $sambaDomain -> minPwdAge ) && ( $sambaDomain -> minPwdAge > 0 ) && ! empty ( $attributes [ 'sambaPwdLastSet' ][ 0 ])) {
$timeVal = $attributes [ 'sambaPwdLastSet' ][ 0 ] + $sambaDomain -> minPwdAge ;
$time = new DateTime ( '@' . $timeVal , new DateTimeZone ( 'UTC' ));
$time -> setTimezone ( getTimeZone ());
$now = new DateTime ( null , getTimeZone ());
if ( $time > $now ) {
$return [ 'messages' ][] = array ( 'ERROR' , _ ( 'You are not yet allowed to change your password.' ));
}
}
2016-05-26 17:41:10 +00:00
}
}
2009-10-08 20:16:02 +00:00
/**
* This method specifies if a module manages password attributes .
* @ see passwordService :: managesPasswordAttributes
*
* @ return boolean true if this module manages password attributes
*/
public function managesPasswordAttributes () {
if ( $this -> get_scope () == " user " ) {
return true ;
}
}
2012-01-15 19:34:14 +00:00
/**
* Specifies if this module supports to force that a user must change his password on next login .
2015-08-06 19:20:54 +00:00
*
2012-01-15 19:34:14 +00:00
* @ return boolean force password change supported
*/
public function supportsForcePasswordChange () {
return true ;
}
2015-08-06 19:20:54 +00:00
2009-10-08 20:16:02 +00:00
/**
2009-10-09 18:21:12 +00:00
* This function is called whenever the password should be changed . Account modules
* must change their password attributes only if the modules list contains their module name .
*
2009-10-08 20:16:02 +00:00
* @ param String $password new password
2009-10-09 18:21:12 +00:00
* @ param $modules list of modules for which the password should be changed
2012-01-15 19:34:14 +00:00
* @ param boolean $forcePasswordChange force the user to change his password at next login
2009-10-08 20:16:02 +00:00
* @ return array list of error messages if any as parameter array for StatusMessage
2020-02-24 19:08:28 +00:00
* e . g . return array ( array ( 'ERROR' , 'Password change failed.' ))
2009-10-09 18:21:12 +00:00
* @ see passwordService :: passwordChangeRequested
2009-10-08 20:16:02 +00:00
*/
2012-01-15 19:34:14 +00:00
public function passwordChangeRequested ( $password , $modules , $forcePasswordChange ) {
2009-10-09 18:21:12 +00:00
if ( ! in_array ( get_class ( $this ), $modules )) {
return array ();
}
2016-05-22 07:56:32 +00:00
$errors = array ();
2009-10-09 18:21:12 +00:00
if ( isset ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ]) && ( $this -> moduleSettings [ 'sambaSamAccount_lmHash' ][ 0 ] == 'no' )) {
$this -> attributes [ 'sambaLMPassword' ][ 0 ] = lmPassword ( $password );
}
$this -> attributes [ 'sambaNTPassword' ][ 0 ] = ntPassword ( $password );
$this -> attributes [ 'sambaPwdLastSet' ][ 0 ] = time ();
2012-01-15 19:34:14 +00:00
if ( $forcePasswordChange ) {
$this -> attributes [ 'sambaPwdLastSet' ][ 0 ] = '0' ;
}
2016-05-20 17:38:36 +00:00
// password history entry
2016-05-26 17:41:10 +00:00
$sambaDomain = $this -> getUserDomain ( $this -> attributes );
2016-05-22 07:56:32 +00:00
if ( $sambaDomain != null ) {
// password history check
2016-05-26 17:41:10 +00:00
$oldPasswordUsed = sambaSamAccount :: oldPasswordUsed ( $password , $this -> orig , $sambaDomain );
2016-05-22 07:56:32 +00:00
if ( $oldPasswordUsed ) {
$errors [] = array ( 'ERROR' , _ ( 'You are reusing an old password. Please choose a different password.' ));
}
// set new history entry
$historyLength = $sambaDomain -> pwdHistoryLength ;
2016-07-09 06:26:05 +00:00
if ( sambaSamAccount :: isPasswordHistoryEnabled ( $this -> moduleSettings ) && ! $oldPasswordUsed && ! empty ( $historyLength ) && is_numeric ( $historyLength ) && ( $historyLength > 0 )) {
2016-05-22 07:56:32 +00:00
if ( ! empty ( $this -> orig [ 'sambaPasswordHistory' ][ 0 ])) {
$this -> attributes [ 'sambaPasswordHistory' ] = $this -> orig [ 'sambaPasswordHistory' ];
}
else {
$this -> attributes [ 'sambaPasswordHistory' ] = array ();
}
while ( sizeof ( $this -> attributes [ 'sambaPasswordHistory' ]) > ( $historyLength - 1 )) {
2016-07-09 06:26:05 +00:00
if ( empty ( $this -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ]) || ( $this -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ] == 'yes_deleteLast' )) {
array_pop ( $this -> attributes [ 'sambaPasswordHistory' ]);
}
else {
array_shift ( $this -> attributes [ 'sambaPasswordHistory' ]);
}
}
if ( empty ( $this -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ]) || ( $this -> moduleSettings [ 'sambaSamAccount_history' ][ 0 ] == 'yes_deleteLast' )) {
array_unshift ( $this -> attributes [ 'sambaPasswordHistory' ], sambaSamAccount :: createHistoryEntry ( $password ));
}
else {
$this -> attributes [ 'sambaPasswordHistory' ][] = sambaSamAccount :: createHistoryEntry ( $password );
2016-05-22 07:56:32 +00:00
}
$this -> attributes [ 'sambaPasswordHistory' ] = array_values ( $this -> attributes [ 'sambaPasswordHistory' ]);
}
}
return $errors ;
}
/**
* Returns if an old password is used .
*
* @ param String $password new password
*/
2016-05-27 19:17:22 +00:00
public static function oldPasswordUsed ( $password , $attributes , $sambaDomain ) {
$attributes = array_change_key_case ( $attributes , CASE_LOWER );
if ( empty ( $attributes [ 'sambapasswordhistory' ][ 0 ]) || ( $sambaDomain == null )
2016-05-22 07:56:32 +00:00
|| ! is_numeric ( $sambaDomain -> pwdHistoryLength ) || ( $sambaDomain -> pwdHistoryLength < 1 )) {
return false ;
}
2016-05-27 19:17:22 +00:00
foreach ( $attributes [ 'sambapasswordhistory' ] as $historyEntry ) {
2016-05-22 07:56:32 +00:00
if ( sambaSamAccount :: validateHistoryEntry ( $password , $historyEntry )) {
return true ;
}
}
return false ;
}
/**
* Returns the domain object of the user ' s domain .
*
2016-05-26 17:41:10 +00:00
* @ param array $attributes LDAP attributes
* @ param handle $server LDAP connection ( leave empty for admin interface )
* @ param String $suffix LDAP search suffix ( leave empty for admin interface )
2016-05-22 07:56:32 +00:00
* @ return samba3domain domain
*/
2016-05-26 17:41:10 +00:00
public function getUserDomain ( $attributes , $server = null , $suffix = null ) {
$attributes = array_change_key_case ( $attributes , CASE_LOWER );
$sambaDomains = $this -> getDomains ( $server , $suffix );
2016-05-20 17:38:36 +00:00
if ( sizeof ( $sambaDomains ) > 0 ) {
2016-05-22 07:56:32 +00:00
$domainSID = null ;
2016-05-26 17:41:10 +00:00
if ( isset ( $attributes [ 'sambasid' ][ 0 ]) && $attributes [ 'sambasid' ][ 0 ] != '' ) {
$domainSID = substr ( $attributes [ 'sambasid' ][ 0 ], 0 , strrpos ( $attributes [ 'sambasid' ][ 0 ], " - " ));
2016-05-20 17:38:36 +00:00
}
for ( $i = 0 ; $i < count ( $sambaDomains ); $i ++ ) {
if ( ! empty ( $domainSID )) {
if (( $domainSID == $sambaDomains [ $i ] -> SID ) && ! empty ( $sambaDomains [ $i ] -> pwdHistoryLength )) {
2016-05-22 07:56:32 +00:00
return $sambaDomains [ $i ];
2016-05-20 17:38:36 +00:00
}
}
2016-05-26 17:41:10 +00:00
elseif ( isset ( $attributes [ 'sambadomainname' ][ 0 ]) && ( $attributes [ 'sambadomainname' ][ 0 ] != '' )) {
if (( $attributes [ 'sambadomainname' ][ 0 ] == $sambaDomains [ $i ] -> name ) && ! empty ( $sambaDomains [ $i ] -> pwdHistoryLength )) {
2016-05-22 07:56:32 +00:00
return $sambaDomains [ $i ];
2016-05-20 17:38:36 +00:00
}
}
}
}
2016-05-22 07:56:32 +00:00
return null ;
2009-10-08 20:16:02 +00:00
}
2015-08-06 19:20:54 +00:00
2009-11-26 10:55:07 +00:00
/**
* Returns the group name of the group with the given group ID .
*
* @ param String $groupID group ID
* @ return String group name
*/
private function getGroupName ( $groupID ) {
$results = searchLDAPByAttribute ( 'gidNumber' , $groupID , 'posixGroup' , array ( 'cn' ), array ( 'group' ));
if (( sizeof ( $results ) > 0 ) && isset ( $results [ 0 ][ 'cn' ][ 0 ])) {
return $results [ 0 ][ 'cn' ][ 0 ];
}
return null ;
}
2015-08-06 19:20:54 +00:00
2010-01-19 18:16:52 +00:00
/**
* Returns the time when the user needs to change his password .
*
* @ param array $domains list of domain objects
* @ param String $selectedDomain selected domain name
*/
private function getPasswordMustChangeTime ( $domains , $selectedDomain ) {
if ( is_array ( $selectedDomain ) && ( sizeof ( $selectedDomain ) > 0 )) {
$selectedDomain = $selectedDomain [ 0 ];
}
2017-04-18 16:28:10 +00:00
$return = '-' ;
2010-01-19 18:16:52 +00:00
// check if password expires at all
if ( $this -> noexpire ) {
2015-08-06 19:20:54 +00:00
return $return ;
2010-01-19 18:16:52 +00:00
}
// check if there is a time set for the last password change
if ( ! isset ( $this -> attributes [ 'sambaPwdLastSet' ][ 0 ])) {
return $return ;
}
for ( $i = 0 ; $i < sizeof ( $domains ); $i ++ ) {
if ( $domains [ $i ] -> name == $selectedDomain ) {
// check if a domain policy is set
if ( ! isset ( $domains [ $i ] -> maxPwdAge ) || ( $domains [ $i ] -> maxPwdAge < 0 )) {
return $return ;
}
2015-08-23 17:56:27 +00:00
$timeVal = $this -> attributes [ 'sambaPwdLastSet' ][ 0 ] + $domains [ $i ] -> maxPwdAge ;
2015-11-07 09:14:48 +00:00
$time = new DateTime ( '@' . $timeVal , new DateTimeZone ( 'UTC' ));
$time -> setTimezone ( getTimeZone ());
2015-08-23 17:56:27 +00:00
return $time -> format ( 'd.m.Y H:i' );
2010-01-19 18:16:52 +00:00
}
}
return $return ;
}
2015-08-06 19:20:54 +00:00
2010-01-19 18:16:52 +00:00
/**
* Returns the time when the user can change his password .
*
* @ param array $domains list of domain objects
* @ param String $selectedDomain selected domain name
*/
private function getPasswordCanChangeTime ( $domains , $selectedDomain ) {
if ( is_array ( $selectedDomain ) && ( sizeof ( $selectedDomain ) > 0 )) {
$selectedDomain = $selectedDomain [ 0 ];
}
2017-04-18 16:28:10 +00:00
$return = '-' ;
2010-01-19 18:16:52 +00:00
// check if there is a time set for the last password change
if ( ! isset ( $this -> attributes [ 'sambaPwdLastSet' ][ 0 ])) {
return $return ;
}
for ( $i = 0 ; $i < sizeof ( $domains ); $i ++ ) {
if ( $domains [ $i ] -> name == $selectedDomain ) {
// check if a domain policy is set
if ( ! isset ( $domains [ $i ] -> minPwdAge ) || ( $domains [ $i ] -> minPwdAge < 0 )) {
return $return ;
}
2015-08-23 17:56:27 +00:00
$timeVal = $this -> attributes [ 'sambaPwdLastSet' ][ 0 ] + $domains [ $i ] -> minPwdAge ;
2015-11-07 09:14:48 +00:00
$time = new DateTime ( '@' . $timeVal , new DateTimeZone ( 'UTC' ));
$time -> setTimezone ( getTimeZone ());
2015-08-23 17:56:27 +00:00
return $time -> format ( 'd.m.Y H:i' );
2010-01-19 18:16:52 +00:00
}
}
return $return ;
}
2015-08-06 19:20:54 +00:00
2010-11-21 14:32:42 +00:00
/**
* Returns a list of existing hosts .
*
* @ return array host names
*/
private function getHostList () {
if ( $this -> cachedHostList != null ) {
return $this -> cachedHostList ;
}
$this -> cachedHostList = searchLDAPByAttribute ( 'uid' , '*' , 'sambaSamAccount' , array ( 'uid' ), array ( 'host' ));
for ( $i = 0 ; $i < sizeof ( $this -> cachedHostList ); $i ++ ) {
$this -> cachedHostList [ $i ] = $this -> cachedHostList [ $i ][ 'uid' ][ 0 ];
}
return $this -> cachedHostList ;
}
/**
* Returns a list of existing hosts .
*
* @ return array host names
*/
private function getGroupSIDList () {
if ( $this -> cachedGroupSIDList != null ) {
return $this -> cachedGroupSIDList ;
}
$this -> cachedGroupSIDList = array ();
$result = searchLDAPByAttribute ( 'sambaSID' , '*' , 'sambaGroupMapping' , array ( 'gidNumber' , 'sambaSID' ), array ( 'group' ));
for ( $i = 0 ; $i < sizeof ( $result ); $i ++ ) {
if ( isset ( $result [ $i ][ 'gidnumber' ][ 0 ])) {
$this -> cachedGroupSIDList [ $result [ $i ][ 'gidnumber' ][ 0 ]] = $result [ $i ][ 'sambasid' ][ 0 ];
}
}
return $this -> cachedGroupSIDList ;
}
2010-11-21 19:23:12 +00:00
/**
* Returns a list of existing Samba 3 domains .
*
2016-05-26 17:41:10 +00:00
* @ param handle $server LDAP connection ( leave empty for admin interface )
* @ param String $suffix LDAP search suffix ( leave empty for admin interface )
2010-11-21 19:23:12 +00:00
* @ return array list of samba3domain objects
*/
2016-05-26 17:41:10 +00:00
private function getDomains ( $server = null , $suffix = null ) {
2010-11-21 19:23:12 +00:00
if ( $this -> cachedDomainList != null ) {
return $this -> cachedDomainList ;
}
2016-05-26 17:41:10 +00:00
$this -> cachedDomainList = search_domains ( $server , $suffix );
2010-11-21 19:23:12 +00:00
return $this -> cachedDomainList ;
}
2011-02-24 19:30:00 +00:00
/**
* Sets the expiration date of this account .
* If all parameters are null the expiration date will be removed .
*
* @ param String $year year ( e . g . 2040 )
* @ param String $month month ( e . g . 8 )
* @ param String $day day ( e . g . 27 )
*/
public function setExpirationDate ( $year , $month , $day ) {
if (( $year == null ) && ( $month == null ) && ( $day == null )) {
unset ( $this -> attributes [ 'sambaKickoffTime' ]);
return ;
}
2016-07-20 18:19:26 +00:00
$date = DateTime :: createFromFormat ( 'j.n.Y' , $day . '.' . $month . '.' . $year , getTimeZone ());
$this -> attributes [ 'sambaKickoffTime' ][ 0 ] = $date -> format ( 'U' );
2011-02-24 19:30:00 +00:00
}
2015-08-06 19:20:54 +00:00
2012-04-09 13:20:24 +00:00
/**
* Returns if the Samba extension is enabled .
2015-08-06 19:20:54 +00:00
*
2012-04-09 13:20:24 +00:00
* @ return boolean Samba extension is active
*/
public function isExtensionEnabled () {
return in_array ( 'sambaSamAccount' , $this -> attributes [ 'objectClass' ]);
}
2015-08-06 19:20:54 +00:00
2012-04-09 13:20:24 +00:00
/**
* Returns if the Samba part of the current account is deactivated .
2015-08-06 19:20:54 +00:00
*
2012-04-09 13:20:24 +00:00
* @ return boolean account is locked
*/
public function isDeactivated () {
return $this -> deactivated ;
}
2015-08-06 19:20:54 +00:00
2012-04-09 13:20:24 +00:00
/**
* Deactivates this account .
*/
public function deactivate () {
$this -> deactivated = true ;
2012-04-09 18:07:57 +00:00
$flags = $this -> attributes [ 'sambaAcctFlags' ][ 0 ];
if ( strpos ( $flags , 'D' ) === false ) {
$flags [ strpos ( $flags , ' ' )] = 'D' ;
}
$this -> attributes [ 'sambaAcctFlags' ][ 0 ] = $flags ;
2012-04-09 13:20:24 +00:00
}
2015-08-06 19:20:54 +00:00
2012-04-09 13:20:24 +00:00
/**
* Activates this account .
*/
public function activate () {
$this -> deactivated = false ;
2012-04-09 18:07:57 +00:00
$this -> attributes [ 'sambaAcctFlags' ][ 0 ] = str_replace ( 'D' , '' , $this -> attributes [ 'sambaAcctFlags' ][ 0 ]);
$this -> attributes [ 'sambaAcctFlags' ][ 0 ] = str_replace ( ']' , ' ]' , $this -> attributes [ 'sambaAcctFlags' ][ 0 ]);
2012-04-09 13:20:24 +00:00
}
2015-08-06 19:20:54 +00:00
2016-05-20 17:38:36 +00:00
/**
* Creates the value to store in sambaPasswordHistory attribute .
*
* @ param String $password password
* @ return String value for sambaPasswordHistory
*/
public static function createHistoryEntry ( $password ) {
if ( empty ( $password )) {
return null ;
}
$salt = generateSalt ( 16 );
$saltHex = bin2hex ( $salt );
$md4hash = ntPassword ( $password );
$md5hash = md5 ( $salt . hex2bin ( $md4hash ));
return strtoupper ( $saltHex . $md5hash );
}
/**
* Checks if the given password matches the history entry .
*
* @ param String $password password
* @ param String $historyEntry sambaPasswordHistory entry
* @ return Boolean entry matches password
*/
public static function validateHistoryEntry ( $password , $historyEntry ) {
if ( empty ( $historyEntry ) || ( strlen ( $historyEntry ) != 64 )) {
return false ;
}
$salt = hex2bin ( substr ( $historyEntry , 0 , 32 ));
$hash = substr ( $historyEntry , 32 , 32 );
$md4hash = ntPassword ( $password );
$md5hash = md5 ( $salt . hex2bin ( $md4hash ));
return strtolower ( $md5hash ) == strtolower ( $hash );
}
2016-07-09 06:26:05 +00:00
/**
* Returns if password history is enabled .
*
* @ param array $settings server profile or self service settings
*/
public static function isPasswordHistoryEnabled ( $settings ) {
return empty ( $settings [ 'sambaSamAccount_history' ]) || ( $settings [ 'sambaSamAccount_history' ][ 0 ] != 'no' );
}
2004-03-09 12:03:39 +00:00
}
2003-12-20 21:42:52 +00:00
?>