2008-05-08 13:23:38 +04:00
/*
Samba Unix / Linux SMB client library
Distributed SMB / CIFS Server Management Utility
2006-02-05 01:01:30 +03:00
Copyright ( C ) 2006 Volker Lendecke ( vl @ samba . org )
2006-02-05 00:44:57 +03: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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2006-02-05 00:44:57 +03:00
( at your option ) any later version .
2008-05-08 13:23:38 +04:00
2006-02-05 00:44:57 +03:00
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 .
2008-05-08 13:23:38 +04:00
2006-02-05 00:44:57 +03:00
You should have received a copy of the GNU General Public License
2008-05-10 01:22:12 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2006-02-05 00:44:57 +03:00
# include "includes.h"
# include "utils/net.h"
2011-04-13 16:32:16 +04:00
# include "rpc_client/rpc_client.h"
2011-01-17 20:16:06 +03:00
# include "../librpc/gen_ndr/ndr_samr_c.h"
2010-10-12 08:27:50 +04:00
# include "../libcli/security/security.h"
2006-02-05 00:44:57 +03:00
/*
* Do something with the account policies . Read them all , run a function on
* them and possibly write them back . " fn " has to return the container index
* it has modified , it can return 0 for no change .
*/
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_do ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv ,
2008-05-10 01:22:12 +04:00
int ( * fn ) ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv ) )
{
2009-03-19 00:49:41 +03:00
struct policy_handle connect_pol , domain_pol ;
2011-01-17 20:16:06 +03:00
NTSTATUS status , result ;
2008-02-05 17:56:05 +03:00
union samr_DomainInfo * info1 = NULL ;
union samr_DomainInfo * info3 = NULL ;
union samr_DomainInfo * info12 = NULL ;
2006-02-05 00:44:57 +03:00
int store ;
2011-01-17 20:16:06 +03:00
struct dcerpc_binding_handle * b = pipe_hnd - > binding_handle ;
2006-02-05 00:44:57 +03:00
ZERO_STRUCT ( connect_pol ) ;
ZERO_STRUCT ( domain_pol ) ;
/* Get sam policy handle */
2008-02-04 21:43:07 +03:00
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_Connect2 ( b , mem_ctx ,
2008-04-19 23:56:43 +04:00
pipe_hnd - > desthost ,
2008-02-04 21:43:07 +03:00
MAXIMUM_ALLOWED_ACCESS ,
2011-01-17 20:16:06 +03:00
& connect_pol ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2006-02-05 00:44:57 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
2011-01-17 20:16:06 +03:00
status = result ;
2006-02-05 00:44:57 +03:00
goto done ;
}
2008-05-08 13:23:38 +04:00
2006-02-05 00:44:57 +03:00
/* Get domain policy handle */
2008-02-01 13:12:05 +03:00
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_OpenDomain ( b , mem_ctx ,
2008-02-01 13:12:05 +03:00
& connect_pol ,
MAXIMUM_ALLOWED_ACCESS ,
ctx - > domain_sid ,
2011-01-17 20:16:06 +03:00
& domain_pol ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2006-02-05 00:44:57 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
2011-01-17 20:16:06 +03:00
status = result ;
2006-02-05 00:44:57 +03:00
goto done ;
}
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_QueryDomainInfo ( b , mem_ctx ,
2008-02-05 17:56:05 +03:00
& domain_pol ,
1 ,
2011-01-17 20:16:06 +03:00
& info1 ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2006-02-05 00:44:57 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
2011-01-17 20:16:06 +03:00
status = result ;
2009-08-10 22:38:33 +04:00
d_fprintf ( stderr , _ ( " query_domain_info level 1 failed: %s \n " ) ,
2006-02-05 00:44:57 +03:00
nt_errstr ( result ) ) ;
goto done ;
}
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_QueryDomainInfo ( b , mem_ctx ,
2008-02-05 17:56:05 +03:00
& domain_pol ,
3 ,
2011-01-17 20:16:06 +03:00
& info3 ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2006-02-05 00:44:57 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
2011-01-17 20:16:06 +03:00
status = result ;
2009-08-10 22:38:33 +04:00
d_fprintf ( stderr , _ ( " query_domain_info level 3 failed: %s \n " ) ,
2006-02-05 00:44:57 +03:00
nt_errstr ( result ) ) ;
goto done ;
}
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_QueryDomainInfo ( b , mem_ctx ,
2008-02-05 17:56:05 +03:00
& domain_pol ,
12 ,
2011-01-17 20:16:06 +03:00
& info12 ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2006-02-05 00:44:57 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
2011-01-17 20:16:06 +03:00
status = result ;
2009-08-10 22:38:33 +04:00
d_fprintf ( stderr , _ ( " query_domain_info level 12 failed: %s \n " ) ,
2006-02-05 00:44:57 +03:00
nt_errstr ( result ) ) ;
goto done ;
}
2008-05-10 01:22:12 +04:00
store = fn ( c , mem_ctx , ctx , & info1 - > info1 , & info3 - > info3 ,
2008-02-05 17:56:05 +03:00
& info12 - > info12 , argc , argv ) ;
2006-02-05 00:44:57 +03:00
if ( store < = 0 ) {
/* Don't save anything */
goto done ;
}
switch ( store ) {
case 1 :
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_SetDomainInfo ( b , mem_ctx ,
2008-02-05 17:56:05 +03:00
& domain_pol ,
1 ,
2011-01-17 20:16:06 +03:00
info1 ,
& result ) ;
2006-02-05 00:44:57 +03:00
break ;
case 3 :
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_SetDomainInfo ( b , mem_ctx ,
2008-02-05 17:56:05 +03:00
& domain_pol ,
3 ,
2011-01-17 20:16:06 +03:00
info3 ,
& result ) ;
2006-02-05 00:44:57 +03:00
break ;
case 12 :
2011-01-17 20:16:06 +03:00
status = dcerpc_samr_SetDomainInfo ( b , mem_ctx ,
2008-02-05 17:56:05 +03:00
& domain_pol ,
12 ,
2011-01-17 20:16:06 +03:00
info12 ,
& result ) ;
2006-02-05 00:44:57 +03:00
break ;
default :
2009-08-10 22:38:33 +04:00
d_fprintf ( stderr , _ ( " Got unexpected info level %d \n " ) , store ) ;
2011-01-17 20:16:06 +03:00
status = NT_STATUS_INTERNAL_ERROR ;
2006-02-05 00:44:57 +03:00
goto done ;
}
2011-01-17 20:16:06 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
status = result ;
2006-02-05 00:44:57 +03:00
done :
if ( is_valid_policy_hnd ( & domain_pol ) ) {
2011-01-17 20:16:06 +03:00
dcerpc_samr_Close ( b , mem_ctx , & domain_pol , & result ) ;
2006-02-05 00:44:57 +03:00
}
if ( is_valid_policy_hnd ( & connect_pol ) ) {
2011-01-17 20:16:06 +03:00
dcerpc_samr_Close ( b , mem_ctx , & connect_pol , & result ) ;
2006-02-05 00:44:57 +03:00
}
2011-01-17 20:16:06 +03:00
return status ;
2006-02-05 00:44:57 +03:00
}
2008-05-10 01:22:12 +04:00
static int account_show ( struct net_context * c ,
TALLOC_CTX * mem_ctx , struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 0 ) {
2010-01-19 13:43:54 +03:00
d_fprintf ( stderr , " %s %s \n " , _ ( " Usage: " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Minimum password length: %d \n " ) , i1 - > min_password_length ) ;
d_printf ( _ ( " Password history length: %d \n " ) ,
i1 - > password_history_length ) ;
2006-02-05 00:44:57 +03:00
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Minimum password age: " ) ) ;
2008-02-05 17:56:05 +03:00
if ( ! nt_time_is_zero ( ( NTTIME * ) & i1 - > min_password_age ) ) {
time_t t = nt_time_to_unix_abs ( ( NTTIME * ) & i1 - > min_password_age ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " %d seconds \n " ) , ( int ) t ) ;
2006-02-05 00:44:57 +03:00
} else {
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " not set \n " ) ) ;
2006-02-05 00:44:57 +03:00
}
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Maximum password age: " ) ) ;
2008-02-05 17:56:05 +03:00
if ( nt_time_is_set ( ( NTTIME * ) & i1 - > max_password_age ) ) {
time_t t = nt_time_to_unix_abs ( ( NTTIME * ) & i1 - > max_password_age ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " %d seconds \n " ) , ( int ) t ) ;
2006-02-05 00:44:57 +03:00
} else {
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " not set \n " ) ) ;
2006-02-05 00:44:57 +03:00
}
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Bad logon attempts: %d \n " ) , i12 - > lockout_threshold ) ;
2006-02-05 00:44:57 +03:00
2008-02-05 17:56:05 +03:00
if ( i12 - > lockout_threshold ! = 0 ) {
2006-02-05 00:44:57 +03:00
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Account lockout duration: " ) ) ;
2008-02-05 17:56:05 +03:00
if ( nt_time_is_set ( & i12 - > lockout_duration ) ) {
time_t t = nt_time_to_unix_abs ( & i12 - > lockout_duration ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " %d seconds \n " ) , ( int ) t ) ;
2006-02-05 00:44:57 +03:00
} else {
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " not set \n " ) ) ;
2006-02-05 00:44:57 +03:00
}
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Bad password count reset after: " ) ) ;
2008-02-05 17:56:05 +03:00
if ( nt_time_is_set ( & i12 - > lockout_window ) ) {
time_t t = nt_time_to_unix_abs ( & i12 - > lockout_window ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " %d seconds \n " ) , ( int ) t ) ;
2006-02-05 00:44:57 +03:00
} else {
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " not set \n " ) ) ;
2006-02-05 00:44:57 +03:00
}
}
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Disconnect users when logon hours expire: %s \n " ) ,
nt_time_is_zero ( & i3 - > force_logoff_time ) ? _ ( " yes " ) : _ ( " no " ) ) ;
2006-02-05 00:44:57 +03:00
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " User must logon to change password: %s \n " ) ,
( i1 - > password_properties & 0x2 ) ? _ ( " yes " ) : _ ( " no " ) ) ;
2008-05-08 13:23:38 +04:00
2006-02-05 00:44:57 +03:00
return 0 ; /* Don't save */
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_pol_show ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv ) {
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_show ) ;
}
2008-05-10 01:22:12 +04:00
static int account_set_badpw ( struct net_context * c ,
TALLOC_CTX * mem_ctx , struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 1 ) {
2010-01-19 13:43:54 +03:00
d_fprintf ( stderr , " %s %s <count> \n " , _ ( " Usage: " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2008-02-05 17:56:05 +03:00
i12 - > lockout_threshold = atoi ( argv [ 0 ] ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Setting bad password count to %d \n " ) ,
2008-02-05 17:56:05 +03:00
i12 - > lockout_threshold ) ;
2006-02-05 00:44:57 +03:00
return 12 ;
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_set_badpw ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv )
{
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_set_badpw ) ;
}
2008-05-10 01:22:12 +04:00
static int account_set_lockduration ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 1 ) {
2010-01-19 11:23:42 +03:00
d_fprintf ( stderr , _ ( " Usage: %s <count> \n " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2008-02-05 17:56:05 +03:00
unix_to_nt_time_abs ( & i12 - > lockout_duration , atoi ( argv [ 0 ] ) ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Setting lockout duration to %d seconds \n " ) ,
2008-02-05 17:56:05 +03:00
( int ) nt_time_to_unix_abs ( & i12 - > lockout_duration ) ) ;
2006-02-05 00:44:57 +03:00
return 12 ;
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_set_lockduration ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv )
{
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_set_lockduration ) ;
}
2008-05-10 01:22:12 +04:00
static int account_set_resetduration ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 1 ) {
2010-01-19 11:23:42 +03:00
d_fprintf ( stderr , _ ( " Usage: %s <count> \n " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2008-02-05 17:56:05 +03:00
unix_to_nt_time_abs ( & i12 - > lockout_window , atoi ( argv [ 0 ] ) ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Setting bad password reset duration to %d seconds \n " ) ,
2008-02-05 17:56:05 +03:00
( int ) nt_time_to_unix_abs ( & i12 - > lockout_window ) ) ;
2006-02-05 00:44:57 +03:00
return 12 ;
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_set_resetduration ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv )
{
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_set_resetduration ) ;
}
2008-05-10 01:22:12 +04:00
static int account_set_minpwage ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 1 ) {
2010-01-19 11:23:42 +03:00
d_fprintf ( stderr , _ ( " Usage: %s <count> \n " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2008-02-05 17:56:05 +03:00
unix_to_nt_time_abs ( ( NTTIME * ) & i1 - > min_password_age , atoi ( argv [ 0 ] ) ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Setting minimum password age to %d seconds \n " ) ,
2008-02-05 17:56:05 +03:00
( int ) nt_time_to_unix_abs ( ( NTTIME * ) & i1 - > min_password_age ) ) ;
2006-02-05 00:44:57 +03:00
return 1 ;
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_set_minpwage ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv )
{
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_set_minpwage ) ;
}
2008-05-10 01:22:12 +04:00
static int account_set_maxpwage ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 1 ) {
2010-01-19 11:23:42 +03:00
d_fprintf ( stderr , _ ( " Usage: %s <count> \n " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2008-02-05 17:56:05 +03:00
unix_to_nt_time_abs ( ( NTTIME * ) & i1 - > max_password_age , atoi ( argv [ 0 ] ) ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Setting maximum password age to %d seconds \n " ) ,
2008-02-05 17:56:05 +03:00
( int ) nt_time_to_unix_abs ( ( NTTIME * ) & i1 - > max_password_age ) ) ;
2006-02-05 00:44:57 +03:00
return 1 ;
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_set_maxpwage ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv )
{
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_set_maxpwage ) ;
}
2008-05-10 01:22:12 +04:00
static int account_set_minpwlen ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 1 ) {
2010-01-19 11:23:42 +03:00
d_fprintf ( stderr , _ ( " Usage: %s <count> \n " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2008-02-05 17:56:05 +03:00
i1 - > min_password_length = atoi ( argv [ 0 ] ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Setting minimum password length to %d \n " ) ,
2008-02-05 17:56:05 +03:00
i1 - > min_password_length ) ;
2006-02-05 00:44:57 +03:00
return 1 ;
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_set_minpwlen ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv )
{
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_set_minpwlen ) ;
}
2008-05-10 01:22:12 +04:00
static int account_set_pwhistlen ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
2008-02-05 17:56:05 +03:00
struct samr_DomInfo1 * i1 ,
struct samr_DomInfo3 * i3 ,
struct samr_DomInfo12 * i12 ,
2006-02-05 00:44:57 +03:00
int argc , const char * * argv )
{
if ( argc ! = 1 ) {
2010-01-19 11:23:42 +03:00
d_fprintf ( stderr , _ ( " Usage: %s <count> \n " ) , ctx - > whoami ) ;
2006-02-05 00:44:57 +03:00
return - 1 ;
}
2008-02-05 17:56:05 +03:00
i1 - > password_history_length = atoi ( argv [ 0 ] ) ;
2009-08-10 22:38:33 +04:00
d_printf ( _ ( " Setting password history length to %d \n " ) ,
2008-02-05 17:56:05 +03:00
i1 - > password_history_length ) ;
2006-02-05 00:44:57 +03:00
return 1 ;
}
2008-05-10 01:22:12 +04:00
static NTSTATUS rpc_sh_acct_set_pwhistlen ( struct net_context * c ,
TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx ,
struct rpc_pipe_client * pipe_hnd ,
int argc , const char * * argv )
{
2008-05-10 01:22:12 +04:00
return rpc_sh_acct_do ( c , mem_ctx , ctx , pipe_hnd , argc , argv ,
2006-02-05 00:44:57 +03:00
account_set_pwhistlen ) ;
}
2008-05-10 01:22:12 +04:00
struct rpc_sh_cmd * net_rpc_acct_cmds ( struct net_context * c , TALLOC_CTX * mem_ctx ,
2006-02-05 00:44:57 +03:00
struct rpc_sh_ctx * ctx )
{
static struct rpc_sh_cmd cmds [ 9 ] = {
2012-01-10 14:53:42 +04:00
{ " show " , NULL , & ndr_table_samr , rpc_sh_acct_pol_show ,
2009-08-10 22:38:33 +04:00
N_ ( " Show current account policy settings " ) } ,
2012-01-10 14:53:42 +04:00
{ " badpw " , NULL , & ndr_table_samr , rpc_sh_acct_set_badpw ,
2009-08-10 22:38:33 +04:00
N_ ( " Set bad password count before lockout " ) } ,
2012-01-10 14:53:42 +04:00
{ " lockduration " , NULL , & ndr_table_samr , rpc_sh_acct_set_lockduration ,
2009-08-10 22:38:33 +04:00
N_ ( " Set account lockout duration " ) } ,
2012-01-10 14:53:42 +04:00
{ " resetduration " , NULL , & ndr_table_samr ,
2006-02-05 00:44:57 +03:00
rpc_sh_acct_set_resetduration ,
2009-08-10 22:38:33 +04:00
N_ ( " Set bad password count reset duration " ) } ,
2012-01-10 14:53:42 +04:00
{ " minpwage " , NULL , & ndr_table_samr , rpc_sh_acct_set_minpwage ,
2009-08-10 22:38:33 +04:00
N_ ( " Set minimum password age " ) } ,
2012-01-10 14:53:42 +04:00
{ " maxpwage " , NULL , & ndr_table_samr , rpc_sh_acct_set_maxpwage ,
2009-08-10 22:38:33 +04:00
N_ ( " Set maximum password age " ) } ,
2012-01-10 14:53:42 +04:00
{ " minpwlen " , NULL , & ndr_table_samr , rpc_sh_acct_set_minpwlen ,
2009-08-10 22:38:33 +04:00
N_ ( " Set minimum password length " ) } ,
2012-01-10 14:53:42 +04:00
{ " pwhistlen " , NULL , & ndr_table_samr , rpc_sh_acct_set_pwhistlen ,
2009-08-10 22:38:33 +04:00
N_ ( " Set the password history length " ) } ,
2009-11-08 21:37:26 +03:00
{ NULL , NULL , 0 , NULL , NULL }
2006-02-05 00:44:57 +03:00
} ;
return cmds ;
}