0001-01-01 02:30:17 +02:30
/*
Unix SMB / CIFS implementation .
0001-01-01 02:30:17 +02:30
SAM_ACCOUNT_HANDLE access routines
0001-01-01 02:30:17 +02:30
Copyright ( C ) Andrew Bartlett 2002
0001-01-01 02:30:17 +02:30
Copyright ( C ) Stefan ( metze ) Metzmacher 2002
0001-01-01 02:30:17 +02:30
Copyright ( C ) Jelmer Vernooij 2002
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 . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_SAM
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_domain_sid ( const SAM_ACCOUNT_HANDLE * sampass , const DOM_SID * * sid )
0001-01-01 02:30:17 +02:30
{
NTSTATUS status ;
SAM_DOMAIN_HANDLE * domain ;
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( ! sampass | | ! sid ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( status = sam_get_account_domain ( sampass , & domain ) ) ) {
DEBUG ( 0 , ( " sam_get_account_domain_sid: Can't get domain for account \n " ) ) ;
0001-01-01 02:30:17 +02:30
return status ;
}
return sam_get_domain_sid ( domain , sid ) ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_domain_name ( const SAM_ACCOUNT_HANDLE * sampass , const char * * domain_name )
0001-01-01 02:30:17 +02:30
{
NTSTATUS status ;
SAM_DOMAIN_HANDLE * domain ;
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & domain_name ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( status = sam_get_account_domain ( sampass , & domain ) ) ) {
DEBUG ( 0 , ( " sam_get_account_domain_name: Can't get domain for account \n " ) ) ;
0001-01-01 02:30:17 +02:30
return status ;
}
return sam_get_domain_name ( domain , domain_name ) ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_acct_ctrl ( const SAM_ACCOUNT_HANDLE * sampass , uint16 * acct_ctrl )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & acct_ctrl ) ;
0001-01-01 02:30:17 +02:30
* acct_ctrl = sampass - > private . acct_ctrl ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_logon_time ( const SAM_ACCOUNT_HANDLE * sampass , NTTIME * logon_time )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & logon_time ) ;
0001-01-01 02:30:17 +02:30
* logon_time = sampass - > private . logon_time ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_logoff_time ( const SAM_ACCOUNT_HANDLE * sampass , NTTIME * logoff_time )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & logoff_time ) ;
0001-01-01 02:30:17 +02:30
* logoff_time = sampass - > private . logoff_time ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_kickoff_time ( const SAM_ACCOUNT_HANDLE * sampass , NTTIME * kickoff_time )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & kickoff_time ) ;
0001-01-01 02:30:17 +02:30
* kickoff_time = sampass - > private . kickoff_time ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_pass_last_set_time ( const SAM_ACCOUNT_HANDLE * sampass , NTTIME * pass_last_set_time )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & pass_last_set_time ) ;
0001-01-01 02:30:17 +02:30
* pass_last_set_time = sampass - > private . pass_last_set_time ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_pass_can_change_time ( const SAM_ACCOUNT_HANDLE * sampass , NTTIME * pass_can_change_time )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & pass_can_change_time ) ;
0001-01-01 02:30:17 +02:30
* pass_can_change_time = sampass - > private . pass_can_change_time ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_pass_must_change_time ( const SAM_ACCOUNT_HANDLE * sampass , NTTIME * pass_must_change_time )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & pass_must_change_time ) ;
0001-01-01 02:30:17 +02:30
* pass_must_change_time = sampass - > private . pass_must_change_time ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_logon_divs ( const SAM_ACCOUNT_HANDLE * sampass , uint16 * logon_divs )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & logon_divs ) ;
0001-01-01 02:30:17 +02:30
* logon_divs = sampass - > private . logon_divs ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_hours_len ( const SAM_ACCOUNT_HANDLE * sampass , uint32 * hours_len )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & hours_len ) ;
0001-01-01 02:30:17 +02:30
* hours_len = sampass - > private . hours_len ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_hours ( const SAM_ACCOUNT_HANDLE * sampass , const uint8 * * hours )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & hours ) ;
0001-01-01 02:30:17 +02:30
* hours = sampass - > private . hours ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_nt_pwd ( const SAM_ACCOUNT_HANDLE * sampass , DATA_BLOB * nt_pwd )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
SMB_ASSERT ( ( ! sampass - > private . nt_pw . data )
| | sampass - > private . nt_pw . length = = NT_HASH_LEN ) ;
* nt_pwd = sampass - > private . nt_pw ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_lm_pwd ( const SAM_ACCOUNT_HANDLE * sampass , DATA_BLOB * lm_pwd )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
SMB_ASSERT ( ( ! sampass - > private . lm_pw . data )
| | sampass - > private . lm_pw . length = = LM_HASH_LEN ) ;
* lm_pwd = sampass - > private . lm_pw ;
return NT_STATUS_OK ;
}
/* Return the plaintext password if known. Most of the time
it isn ' t , so don ' t assume anything magic about this function .
Used to pass the plaintext to sam backends that might
want to store more than just the NTLM hashes .
*/
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_plaintext_pwd ( const SAM_ACCOUNT_HANDLE * sampass , char * * plain_pwd )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & plain_pwd ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
* plain_pwd = sampass - > private . plaintext_pw ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_sid ( const SAM_ACCOUNT_HANDLE * sampass , const DOM_SID * * sid )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
* sid = & ( sampass - > private . account_sid ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_pgroup ( const SAM_ACCOUNT_HANDLE * sampass , const DOM_SID * * sid )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* sid = & ( sampass - > private . group_sid ) ;
return NT_STATUS_OK ;
}
/**
0001-01-01 02:30:17 +02:30
* Get flags showing what is initalised in the SAM_ACCOUNT_HANDLE
* @ param sampass the SAM_ACCOUNT_HANDLE in question
0001-01-01 02:30:17 +02:30
* @ return the flags indicating the members initialised in the struct .
* */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_init_flag ( const SAM_ACCOUNT_HANDLE * sampass , uint32 * initflag )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* initflag = sampass - > private . init_flag ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_name ( const SAM_ACCOUNT_HANDLE * sampass , char * * account_name )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
* account_name = sampass - > private . account_name ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_domain ( const SAM_ACCOUNT_HANDLE * sampass , SAM_DOMAIN_HANDLE * * domain )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* domain = sampass - > private . domain ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_fullname ( const SAM_ACCOUNT_HANDLE * sampass , char * * fullname )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* fullname = sampass - > private . full_name ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_homedir ( const SAM_ACCOUNT_HANDLE * sampass , char * * homedir )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* homedir = sampass - > private . home_dir ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_unix_home_dir ( const SAM_ACCOUNT_HANDLE * sampass , char * * uhomedir )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* uhomedir = sampass - > private . unix_home_dir ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_dir_drive ( const SAM_ACCOUNT_HANDLE * sampass , char * * dirdrive )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* dirdrive = sampass - > private . dir_drive ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_logon_script ( const SAM_ACCOUNT_HANDLE * sampass , char * * logon_script )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* logon_script = sampass - > private . logon_script ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_profile_path ( const SAM_ACCOUNT_HANDLE * sampass , char * * profile_path )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* profile_path = sampass - > private . profile_path ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_description ( const SAM_ACCOUNT_HANDLE * sampass , char * * description )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* description = sampass - > private . acct_desc ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_workstations ( const SAM_ACCOUNT_HANDLE * sampass , char * * workstations )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* workstations = sampass - > private . workstations ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_unknown_str ( const SAM_ACCOUNT_HANDLE * sampass , char * * unknown_str )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* unknown_str = sampass - > private . unknown_str ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_munged_dial ( const SAM_ACCOUNT_HANDLE * sampass , char * * munged_dial )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
* munged_dial = sampass - > private . munged_dial ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_unknown_1 ( const SAM_ACCOUNT_HANDLE * sampass , uint32 * unknown1 )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & unknown1 ) ;
0001-01-01 02:30:17 +02:30
* unknown1 = sampass - > private . unknown_1 ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_unknown_2 ( const SAM_ACCOUNT_HANDLE * sampass , uint32 * unknown2 )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & unknown2 ) ;
0001-01-01 02:30:17 +02:30
* unknown2 = sampass - > private . unknown_2 ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_get_account_unknown_3 ( const SAM_ACCOUNT_HANDLE * sampass , uint32 * unknown3 )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & unknown3 ) ;
0001-01-01 02:30:17 +02:30
* unknown3 = sampass - > private . unknown_3 ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Collection of set . . . ( ) functions for SAM_ACCOUNT_HANDLE_INFO .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_acct_ctrl ( SAM_ACCOUNT_HANDLE * sampass , uint16 acct_ctrl )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
sampass - > private . acct_ctrl = acct_ctrl ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_logon_time ( SAM_ACCOUNT_HANDLE * sampass , NTTIME mytime , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . logon_time = mytime ;
return NT_STATUS_UNSUCCESSFUL ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_logoff_time ( SAM_ACCOUNT_HANDLE * sampass , NTTIME mytime , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . logoff_time = mytime ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_kickoff_time ( SAM_ACCOUNT_HANDLE * sampass , NTTIME mytime , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . kickoff_time = mytime ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_pass_can_change_time ( SAM_ACCOUNT_HANDLE * sampass , NTTIME mytime , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . pass_can_change_time = mytime ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_pass_must_change_time ( SAM_ACCOUNT_HANDLE * sampass , NTTIME mytime , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . pass_must_change_time = mytime ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_pass_last_set_time ( SAM_ACCOUNT_HANDLE * sampass , NTTIME mytime )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . pass_last_set_time = mytime ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_hours_len ( SAM_ACCOUNT_HANDLE * sampass , uint32 len )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . hours_len = len ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_logon_divs ( SAM_ACCOUNT_HANDLE * sampass , uint16 hours )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . logon_divs = hours ;
return NT_STATUS_OK ;
}
/**
0001-01-01 02:30:17 +02:30
* Set flags showing what is initalised in the SAM_ACCOUNT_HANDLE
* @ param sampass the SAM_ACCOUNT_HANDLE in question
0001-01-01 02:30:17 +02:30
* @ param flag The * new * flag to be set . Old flags preserved
* this flag is only added .
* */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_init_flag ( SAM_ACCOUNT_HANDLE * sampass , uint32 flag )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . init_flag | = flag ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_sid ( SAM_ACCOUNT_HANDLE * sampass , const DOM_SID * u_sid )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & u_sid ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
sid_copy ( & sampass - > private . account_sid , u_sid ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_account_sid: setting account sid %s \n " ,
sid_string_static ( & sampass - > private . account_sid ) ) ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_sid_from_string ( SAM_ACCOUNT_HANDLE * sampass , const char * u_sid )
0001-01-01 02:30:17 +02:30
{
DOM_SID new_sid ;
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & u_sid ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_account_sid_from_string: setting account sid %s \n " ,
0001-01-01 02:30:17 +02:30
u_sid ) ) ;
if ( ! string_to_sid ( & new_sid , u_sid ) ) {
0001-01-01 02:30:17 +02:30
DEBUG ( 1 , ( " sam_set_account_sid_from_string: %s isn't a valid SID! \n " , u_sid ) ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
}
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_set_account_sid ( sampass , & new_sid ) ) ) {
DEBUG ( 1 , ( " sam_set_account_sid_from_string: could not set sid %s on SAM_ACCOUNT_HANDLE! \n " , u_sid ) ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
}
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_pgroup_sid ( SAM_ACCOUNT_HANDLE * sampass , const DOM_SID * g_sid )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & g_sid ) ;
0001-01-01 02:30:17 +02:30
sid_copy ( & sampass - > private . group_sid , g_sid ) ;
DEBUG ( 10 , ( " sam_set_group_sid: setting group sid %s \n " ,
sid_string_static ( & sampass - > private . group_sid ) ) ) ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_pgroup_string ( SAM_ACCOUNT_HANDLE * sampass , const char * g_sid )
0001-01-01 02:30:17 +02:30
{
DOM_SID new_sid ;
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & g_sid ) ;
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_group_sid_from_string: setting group sid %s \n " ,
g_sid ) ) ;
if ( ! string_to_sid ( & new_sid , g_sid ) ) {
DEBUG ( 1 , ( " sam_set_group_sid_from_string: %s isn't a valid SID! \n " , g_sid ) ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_set_account_pgroup_sid ( sampass , & new_sid ) ) ) {
DEBUG ( 1 , ( " sam_set_group_sid_from_string: could not set sid %s on SAM_ACCOUNT_HANDLE! \n " , g_sid ) ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
}
return NT_STATUS_OK ;
}
/*********************************************************************
Set the domain name .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_domain ( SAM_ACCOUNT_HANDLE * sampass , SAM_DOMAIN_HANDLE * domain )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . domain = domain ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s NT name .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_name ( SAM_ACCOUNT_HANDLE * sampass , const char * account_name )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_account_name: setting nt account_name %s, was %s \n " , account_name , sampass - > private . account_name ) ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
sampass - > private . account_name = talloc_strdup ( sampass - > mem_ctx , account_name ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s full name .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_fullname ( SAM_ACCOUNT_HANDLE * sampass , const char * full_name )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_account_fullname: setting full name %s, was %s \n " , full_name , sampass - > private . full_name ) ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . full_name = talloc_strdup ( sampass - > mem_ctx , full_name ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s logon script .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_logon_script ( SAM_ACCOUNT_HANDLE * sampass , const char * logon_script , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_logon_script: from %s to %s \n " , logon_script , sampass - > private . logon_script ) ) ;
sampass - > private . logon_script = talloc_strdup ( sampass - > mem_ctx , logon_script ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s profile path .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_profile_path ( SAM_ACCOUNT_HANDLE * sampass , const char * profile_path , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_profile_path: setting profile path %s, was %s \n " , profile_path , sampass - > private . profile_path ) ) ;
sampass - > private . profile_path = talloc_strdup ( sampass - > mem_ctx , profile_path ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s directory drive .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_dir_drive ( SAM_ACCOUNT_HANDLE * sampass , const char * dir_drive , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_dir_drive: setting dir drive %s, was %s \n " , dir_drive ,
sampass - > private . dir_drive ) ) ;
sampass - > private . dir_drive = talloc_strdup ( sampass - > mem_ctx , dir_drive ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s home directory .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_homedir ( SAM_ACCOUNT_HANDLE * sampass , const char * home_dir , BOOL store )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_homedir: setting home dir %s, was %s \n " , home_dir ,
sampass - > private . home_dir ) ) ;
sampass - > private . home_dir = talloc_strdup ( sampass - > mem_ctx , home_dir ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s unix home directory .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_unix_homedir ( SAM_ACCOUNT_HANDLE * sampass , const char * unix_home_dir )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_unix_homedir: setting home dir %s, was %s \n " , unix_home_dir ,
sampass - > private . unix_home_dir ) ) ;
sampass - > private . unix_home_dir = talloc_strdup ( sampass - > mem_ctx , unix_home_dir ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s account description .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_acct_desc ( SAM_ACCOUNT_HANDLE * sampass , const char * acct_desc )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . acct_desc = talloc_strdup ( sampass - > mem_ctx , acct_desc ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s workstation allowed list .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_workstations ( SAM_ACCOUNT_HANDLE * sampass , const char * workstations )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
DEBUG ( 10 , ( " sam_set_workstations: setting workstations %s, was %s \n " , workstations ,
sampass - > private . workstations ) ) ;
sampass - > private . workstations = talloc_strdup ( sampass - > mem_ctx , workstations ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s ' unknown_str ' , whatever the heck this actually is . . .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_unknown_str ( SAM_ACCOUNT_HANDLE * sampass , const char * unknown_str )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . unknown_str = talloc_strdup ( sampass - > mem_ctx , unknown_str ) ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s dial string .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_munged_dial ( SAM_ACCOUNT_HANDLE * sampass , const char * munged_dial )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . munged_dial = talloc_strdup ( sampass - > mem_ctx , munged_dial ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s NT hash .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_nt_pwd ( SAM_ACCOUNT_HANDLE * sampass , const DATA_BLOB data )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . nt_pw = data ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s LM hash .
0001-01-01 02:30:17 +02:30
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_lm_pwd ( SAM_ACCOUNT_HANDLE * sampass , const DATA_BLOB data )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . lm_pw = data ;
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s plaintext password only ( base procedure , see helper
0001-01-01 02:30:17 +02:30
below )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_plaintext_pwd ( SAM_ACCOUNT_HANDLE * sampass , const char * plain_pwd )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
sampass - > private . plaintext_pw = talloc_strdup ( sampass - > mem_ctx , plain_pwd ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_unknown_1 ( SAM_ACCOUNT_HANDLE * sampass , uint32 unkn )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . unknown_1 = unkn ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_unknown_2 ( SAM_ACCOUNT_HANDLE * sampass , uint32 unkn )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . unknown_2 = unkn ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_unknown_3 ( SAM_ACCOUNT_HANDLE * sampass , uint32 unkn )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
sampass - > private . unknown_3 = unkn ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_hours ( SAM_ACCOUNT_HANDLE * sampass , const uint8 * hours )
0001-01-01 02:30:17 +02:30
{
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
if ( ! hours ) {
memset ( ( char * ) sampass - > private . hours , 0 , MAX_HOURS_LEN ) ;
return NT_STATUS_OK ;
}
0001-01-01 02:30:17 +02:30
memcpy ( sampass - > private . hours , hours , MAX_HOURS_LEN ) ;
0001-01-01 02:30:17 +02:30
return NT_STATUS_OK ;
}
/* Helpful interfaces to the above */
/*********************************************************************
Sets the last changed times and must change times for a normal
password change .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_pass_changed_now ( SAM_ACCOUNT_HANDLE * sampass )
0001-01-01 02:30:17 +02:30
{
uint32 expire ;
NTTIME temptime ;
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass ) ;
0001-01-01 02:30:17 +02:30
unix_to_nt_time ( & temptime , time ( NULL ) ) ;
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_set_account_pass_last_set_time ( sampass , temptime ) ) )
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
if ( ! account_policy_get ( AP_MAX_PASSWORD_AGE , & expire )
| | ( expire = = ( uint32 ) - 1 ) ) {
get_nttime_max ( & temptime ) ;
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_set_account_pass_must_change_time ( sampass , temptime , False ) ) )
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
} else {
/* FIXME: Add expire to temptime */
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_get_account_pass_last_set_time ( sampass , & temptime ) ) | | ! NT_STATUS_IS_OK ( sam_set_account_pass_must_change_time ( sampass , temptime , True ) ) )
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
}
return NT_STATUS_OK ;
}
/*********************************************************************
0001-01-01 02:30:17 +02:30
Set the account ' s PLAINTEXT password . Used as an interface to the above .
0001-01-01 02:30:17 +02:30
Also sets the last change time to NOW .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0001-01-01 02:30:17 +02:30
NTSTATUS sam_set_account_passwd ( SAM_ACCOUNT_HANDLE * sampass , const char * plaintext )
0001-01-01 02:30:17 +02:30
{
DATA_BLOB data ;
uchar new_lanman_p16 [ 16 ] ;
uchar new_nt_p16 [ 16 ] ;
0001-01-01 02:30:17 +02:30
SAM_ASSERT ( sampass & & plaintext ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
nt_lm_owf_gen ( plaintext , new_nt_p16 , new_lanman_p16 ) ;
0001-01-01 02:30:17 +02:30
data = data_blob ( new_nt_p16 , 16 ) ;
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_set_account_nt_pwd ( sampass , data ) ) )
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
data = data_blob ( new_lanman_p16 , 16 ) ;
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_set_account_lm_pwd ( sampass , data ) ) )
return NT_STATUS_UNSUCCESSFUL ;
if ( ! NT_STATUS_IS_OK ( sam_set_account_plaintext_pwd ( sampass , plaintext ) ) )
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
0001-01-01 02:30:17 +02:30
if ( ! NT_STATUS_IS_OK ( sam_set_account_pass_changed_now ( sampass ) ) )
0001-01-01 02:30:17 +02:30
return NT_STATUS_UNSUCCESSFUL ;
return NT_STATUS_OK ;
}