示例#1
0
static NTSTATUS enum_accounts_for_privilege(struct rpc_pipe_client *pipe_hnd,
						TALLOC_CTX *ctx,
						struct policy_handle *pol,
						const char *privilege)
{
	NTSTATUS status, result;
	uint32_t enum_context=0;
	uint32_t pref_max_length=0x1000;
	struct lsa_SidArray sid_array;
	int i;
	fstring name;
	struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;

	status = dcerpc_lsa_EnumAccounts(b, ctx,
					 pol,
					 &enum_context,
					 &sid_array,
					 pref_max_length,
					 &result);
	if (!NT_STATUS_IS_OK(status))
		return status;
	if (!NT_STATUS_IS_OK(result))
		return result;

	d_printf("%s:\n", privilege);

	for ( i=0; i<sid_array.num_sids; i++ ) {

		status = check_privilege_for_user(pipe_hnd, ctx, pol,
						  sid_array.sids[i].sid,
						  privilege);

		if ( ! NT_STATUS_IS_OK(status)) {
			if ( ! NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
				return status;
			}
			continue;
		}

		/* try to convert the SID to a name.  Fall back to
		   printing the raw SID if necessary */
		status = sid_to_name( pipe_hnd, ctx, sid_array.sids[i].sid, name );
		if ( !NT_STATUS_IS_OK (status) )
			sid_to_fstring(name, sid_array.sids[i].sid);

		d_printf("  %s\n", name);
	}

	return NT_STATUS_OK;
}
示例#2
0
static NTSTATUS enum_privileges_for_accounts(struct rpc_pipe_client *pipe_hnd,
						TALLOC_CTX *ctx,
						struct policy_handle *pol)
{
	NTSTATUS result;
	uint32 enum_context=0;
	uint32 pref_max_length=0x1000;
	struct lsa_SidArray sid_array;
	int i;
	fstring name;

	result = rpccli_lsa_EnumAccounts(pipe_hnd, ctx,
					 pol,
					 &enum_context,
					 &sid_array,
					 pref_max_length);

	if (!NT_STATUS_IS_OK(result))
		return result;

	for ( i=0; i<sid_array.num_sids; i++ ) {

		/* try to convert the SID to a name.  Fall back to
		   printing the raw SID if necessary */

		result = sid_to_name(pipe_hnd, ctx, sid_array.sids[i].sid, name);
		if ( !NT_STATUS_IS_OK (result) )
			sid_to_fstring(name, sid_array.sids[i].sid);

		d_printf("%s\n", name);

		result = enum_privileges_for_user(pipe_hnd, ctx, pol,
						  sid_array.sids[i].sid);
		if ( !NT_STATUS_IS_OK(result) )
			return result;

		d_printf("\n");
	}

	return NT_STATUS_OK;
}
示例#3
0
static NTSTATUS enum_privileges_for_accounts( TALLOC_CTX *ctx, struct cli_state *cli,
                                              POLICY_HND *pol )
{
	NTSTATUS result;
	uint32 enum_context=0;
	uint32 pref_max_length=0x1000;
	DOM_SID *sids;
	uint32 count=0;
	int i;
	fstring name;

	result = cli_lsa_enum_sids(cli, ctx, pol, &enum_context, 
		pref_max_length, &count, &sids);

	if (!NT_STATUS_IS_OK(result))
		return result;
		
	for ( i=0; i<count; i++ ) {
	
		/* try to convert the SID to a name.  Fall back to 
		   printing the raw SID if necessary */
		   
		result = sid_to_name( cli, ctx, &sids[i], name );
		if ( !NT_STATUS_IS_OK (result) )
			fstrcpy( name, sid_string_static(&sids[i]) );
			
		d_printf("%s\n", name);
		
		result = enum_privileges_for_user( ctx, cli, pol, &sids[i] );
		
		if ( !NT_STATUS_IS_OK(result) )
			return result;

		d_printf("\n");
	}

	return NT_STATUS_OK;
}