acct_ctrl in context_sam_enum_accounts

Jelmer Vernooij jelmer at samba.org
Fri Sep 27 13:11:01 GMT 2002


On Fri, Sep 27, 2002 at 10:16:28AM +0200, Stefan (metze) Metzmacher wrote about 'Re: acct_ctrl in context_sam_enum_accounts':
> At 18:27 26.09.2002 +0200, Jelmer Vernooij wrote:
> >Hi all!

> >What kind of a value is the acct_ctrl argument of
> >context_sam_enum_accounts supposed to be?

> >It should be possible to list all accounts, that's why the current
> >implementation isn't very usable...

> list all accounts with    acct_ctrl = (ACB_NORMAL | ACB_WSTRUST | 
> ACB_SVRTRUST | ACB_DOMTRUST | ACB_TEMPDUP | ACB_MNS);

> I add a patch for this

Then Kai's sam_passdb handles this wrong... it does a
cur_account.acct_ctrl & given_acct_ctrl, which will not work if
given_acct_ctrl contains all ACB_FLAGS.

I'll commit your patch..

Jelmer


> metze
> -----------------------------------------------------------------------------
> Stefan "metze" Metzmacher <metze at metzemix.de>

> diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* HEAD/source/torture/cmd_sam.c HEAD-fix/source/torture/cmd_sam.c
> --- HEAD/source/torture/cmd_sam.c	Fri Sep 27 07:40:05 2002
> +++ HEAD-fix/source/torture/cmd_sam.c	Fri Sep 27 10:06:19 2002
> @@ -227,13 +227,13 @@ static NTSTATUS cmd_show_domain(struct s
>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_num_groups(domain, &tmp_uint32))) {
>  		printf("sam_get_domain_num_groups failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Number of groups: %d\n", tmp_uint32);
> +		printf("Number of groups: %u\n", tmp_uint32);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_num_aliases(domain, &tmp_uint32))) {
>  		printf("sam_get_domain_num_aliases failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Number of aliases: %d\n", tmp_uint32);
> +		printf("Number of aliases: %u\n", tmp_uint32);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_name(domain, &tmp_string))) {
> @@ -245,7 +245,7 @@ static NTSTATUS cmd_show_domain(struct s
>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_lockout_count(domain, &tmp_uint16))) {
>  		printf("sam_get_domain_lockout_count failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Lockout Count: %d\n", tmp_uint16);
> +		printf("Lockout Count: %u\n", tmp_uint16);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_force_logoff(domain, &tmp_bool))) {
> @@ -257,7 +257,7 @@ static NTSTATUS cmd_show_domain(struct s
>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_lockout_duration(domain, &tmp_nttime))) {
>  		printf("sam_get_domain_lockout_duration failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Lockout duration: %d\n", tmp_nttime.low);
> +		printf("Lockout duration: %u\n", tmp_nttime.low);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_login_pwdchange(domain, &tmp_bool))) {
> @@ -269,31 +269,31 @@ static NTSTATUS cmd_show_domain(struct s
>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_max_pwdage(domain, &tmp_nttime))) {
>  		printf("sam_get_domain_max_pwdage failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Maximum password age: %d\n", tmp_nttime.low);
> +		printf("Maximum password age: %u\n", tmp_nttime.low);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_min_pwdage(domain, &tmp_nttime))) {
>  		printf("sam_get_domain_min_pwdage failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Minimal password age: %d\n", tmp_nttime.low);
> +		printf("Minimal password age: %u\n", tmp_nttime.low);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_min_pwdlength(domain, &tmp_uint16))) {
>  		printf("sam_get_domain_min_pwdlength: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Minimal Password Length: %d\n", tmp_uint16);
> +		printf("Minimal Password Length: %u\n", tmp_uint16);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_pwd_history(domain, &tmp_uint16))) {
>  		printf("sam_get_domain_pwd_history failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Password history: %d\n", tmp_uint16);
> +		printf("Password history: %u\n", tmp_uint16);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_reset_count(domain, &tmp_nttime))) {
>  		printf("sam_get_domain_reset_count failed: %s\n", nt_errstr(status));
>  	} else {
> -		printf("Reset count: %d\n", tmp_nttime.low);
> +		printf("Reset count: %u\n", tmp_nttime.low);
>  	}

>  	if (!NT_STATUS_IS_OK(status = sam_get_domain_server(domain, &tmp_string))) {
> @@ -326,6 +326,7 @@ static NTSTATUS cmd_enum_accounts(struct
>  	DOM_SID sid;
>  	int32 account_count, i;
>  	SAM_ACCOUNT_ENUM *accounts;
> +	uint16 acct_ctrl = (ACB_NORMAL |ACB_WSTRUST |ACB_SVRTRUST |ACB_DOMTRUST | ACB_MNS);

>  	if (argc != 2) {
>  		printf("Usage: enum_accounts <domain-sid>\n");
> @@ -337,7 +338,7 @@ static NTSTATUS cmd_enum_accounts(struct
>  		return NT_STATUS_INVALID_PARAMETER;
>  	}

> -	if (!NT_STATUS_IS_OK(status = context_sam_enum_accounts(st->context, st->token, &sid, 0, &account_count, &accounts))) {
> +	if (!NT_STATUS_IS_OK(status = context_sam_enum_accounts(st->context, st->token, &sid, acct_ctrl, &account_count, &accounts))) {
>  		printf("context_sam_enum_accounts failed: %s\n", nt_errstr(status));
>  		return status;
>  	}
> @@ -348,7 +349,7 @@ static NTSTATUS cmd_enum_accounts(struct
>  	}

>  	for (i = 0; i < account_count; i++)
> -		printf("%s\t%s\t%s\t%s\t%d\n", 
> +		printf("SID: %s\nName: %s\nFullname: %s\nDescription: %s\nACB_BITS: %08X\n\n", 
>  			   sid_string_static(&accounts[i].sid), accounts[i].account_name,
>  			   accounts[i].full_name, accounts[i].account_desc, 
>  			   accounts[i].acct_ctrl);


-- 
Jelmer Vernooij <jelmer at nl.linux.org> - http://nl.linux.org/~jelmer/
Development And Underdevelopment: http://library.thinkquest.org/C0110231/
Listening to 
 15:08:42 up 2 min,  3 users,  load average: 0.12, 0.10, 0.04



More information about the samba-technical mailing list