1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

Use rpccli_lsa_LookupPrivDisplayName() in net and rpcclient.

Guenther
(This used to be commit be932cbdfa)
This commit is contained in:
Günther Deschner 2008-02-11 12:17:27 +01:00
parent 419ab84b01
commit 7b50295400
2 changed files with 51 additions and 21 deletions

View File

@ -22,6 +22,10 @@
#include "includes.h"
#include "rpcclient.h"
static void init_lsa_String(struct lsa_String *name, const char *s)
{
name->string = s;
}
/* useful function to allow entering a name instead of a SID and
* looking it up automatically */
@ -501,7 +505,8 @@ static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli,
uint16 lang_id=0;
uint16 lang_id_sys=0;
uint16 lang_id_desc;
fstring description;
struct lsa_String lsa_name;
struct lsa_StringLarge *description = NULL;
if (argc != 2) {
printf("Usage: %s privilege name\n", argv[0]);
@ -515,13 +520,21 @@ static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
result = rpccli_lsa_get_dispname(cli, mem_ctx, &pol, argv[1], lang_id, lang_id_sys, description, &lang_id_desc);
init_lsa_String(&lsa_name, argv[1]);
result = rpccli_lsa_LookupPrivDisplayName(cli, mem_ctx,
&pol,
&lsa_name,
lang_id,
lang_id_sys,
&description,
&lang_id_desc);
if (!NT_STATUS_IS_OK(result))
goto done;
/* Print results */
printf("%s -> %s (language: 0x%x)\n", argv[1], description, lang_id_desc);
printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc);
rpccli_lsa_Close(cli, mem_ctx, &pol);
done:
@ -983,11 +996,6 @@ static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
return result;
}
static void init_lsa_String(struct lsa_String *name, const char *s)
{
name->string = s;
}
static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)

View File

@ -19,6 +19,11 @@
#include "includes.h"
#include "utils/net.h"
static void init_lsa_String(struct lsa_String *name, const char *s)
{
name->string = s;
}
/********************************************************************
********************************************************************/
@ -98,7 +103,7 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd,
uint16 lang_id=0;
uint16 lang_id_sys=0;
uint16 lang_id_desc;
fstring description;
struct lsa_StringLarge *description = NULL;
struct lsa_PrivArray priv_array;
result = rpccli_lsa_EnumPrivs(pipe_hnd, ctx,
@ -113,19 +118,30 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd,
/* Print results */
for (i = 0; i < priv_array.count; i++) {
struct lsa_String lsa_name;
d_printf("%30s ",
priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*" );
/* try to get the description */
if ( !NT_STATUS_IS_OK(rpccli_lsa_get_dispname(pipe_hnd, ctx, pol,
priv_array.privs[i].name.string, lang_id, lang_id_sys, description, &lang_id_desc)) )
{
init_lsa_String(&lsa_name, priv_array.privs[i].name.string);
result = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, ctx,
pol,
&lsa_name,
lang_id,
lang_id_sys,
&description,
&lang_id_desc);
if (!NT_STATUS_IS_OK(result)) {
d_printf("??????\n");
continue;
}
d_printf("%s\n", description );
d_printf("%s\n", description->string);
}
return NT_STATUS_OK;
@ -298,7 +314,8 @@ static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid,
NTSTATUS result;
DOM_SID sid;
fstring privname;
fstring description;
struct lsa_String lsa_name;
struct lsa_StringLarge *description = NULL;
uint16 lang_id = 0;
uint16 lang_id_sys = 0;
uint16 lang_id_desc;
@ -326,14 +343,19 @@ static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid,
}
while ( argv[i] != NULL ) {
fstrcpy( privname, argv[i] );
fstrcpy(privname, argv[i]);
init_lsa_String(&lsa_name, argv[i]);
i++;
/* verify that this is a valid privilege for error reporting */
result = rpccli_lsa_get_dispname(pipe_hnd, mem_ctx, &pol, privname, lang_id,
lang_id_sys, description, &lang_id_desc);
result = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, mem_ctx,
&pol,
&lsa_name,
lang_id,
lang_id_sys,
&description,
&lang_id_desc);
if ( !NT_STATUS_IS_OK(result) ) {
if ( NT_STATUS_EQUAL( result, NT_STATUS_NO_SUCH_PRIVILEGE ) )
d_fprintf(stderr, "No such privilege exists: %s.\n", privname);