summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/netapi/localgroup.c190
1 files changed, 188 insertions, 2 deletions
diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c
index 09b86c8bd9..d05ebd3457 100644
--- a/source3/lib/netapi/localgroup.c
+++ b/source3/lib/netapi/localgroup.c
@@ -350,11 +350,197 @@ WERROR NetLocalGroupDel_l(struct libnetapi_ctx *ctx,
/****************************************************************
****************************************************************/
+static WERROR map_alias_info_to_buffer(TALLOC_CTX *mem_ctx,
+ struct samr_AliasInfoAll *info,
+ uint32_t level,
+ uint8_t **buffer)
+{
+ struct LOCALGROUP_INFO_0 g0;
+ struct LOCALGROUP_INFO_1 g1;
+ struct LOCALGROUP_INFO_1002 g1002;
+
+ switch (level) {
+ case 0:
+ g0.lgrpi0_name = info->name.string;
+
+ *buffer = (uint8_t *)talloc_memdup(mem_ctx, &g0, sizeof(g0));
+
+ break;
+ case 1:
+ g1.lgrpi1_name = info->name.string;
+ g1.lgrpi1_comment = info->description.string;
+
+ *buffer = (uint8_t *)talloc_memdup(mem_ctx, &g1, sizeof(g1));
+
+ break;
+ case 1002:
+ g1002.lgrpi1002_comment = info->description.string;
+
+ *buffer = (uint8_t *)talloc_memdup(mem_ctx, &g1002, sizeof(g1002));
+
+ break;
+ default:
+ return WERR_UNKNOWN_LEVEL;
+ }
+
+ W_ERROR_HAVE_NO_MEMORY(*buffer);
+
+ return WERR_OK;
+}
+
+/****************************************************************
+****************************************************************/
WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
struct NetLocalGroupGetInfo *r)
{
- return WERR_NOT_SUPPORTED;
+ struct cli_state *cli = NULL;
+ struct rpc_pipe_client *pipe_cli = NULL;
+ NTSTATUS status;
+ WERROR werr;
+ struct lsa_String lsa_account_name;
+ struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle;
+ struct samr_Ids user_rids, name_types;
+ struct dom_sid2 *domain_sid = NULL;
+ union samr_AliasInfo *alias_info = NULL;
+
+ if (!r->in.group_name) {
+ return WERR_INVALID_PARAM;
+ }
+
+ switch (r->in.level) {
+ case 0:
+ case 1:
+ case 1002:
+ break;
+ default:
+ return WERR_UNKNOWN_LEVEL;
+ }
+
+ ZERO_STRUCT(connect_handle);
+ ZERO_STRUCT(builtin_handle);
+ ZERO_STRUCT(domain_handle);
+ ZERO_STRUCT(alias_handle);
+
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ status = rpccli_try_samr_connects(pipe_cli, ctx,
+ SAMR_ACCESS_OPEN_DOMAIN |
+ SAMR_ACCESS_ENUM_DOMAINS,
+ &connect_handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ status = rpccli_samr_OpenDomain(pipe_cli, ctx,
+ &connect_handle,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ CONST_DISCARD(DOM_SID *, &global_sid_Builtin),
+ &builtin_handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ init_lsa_String(&lsa_account_name, r->in.group_name);
+
+ status = rpccli_samr_LookupNames(pipe_cli, ctx,
+ &builtin_handle,
+ 1,
+ &lsa_account_name,
+ &user_rids,
+ &name_types);
+ if (NT_STATUS_IS_OK(status)) {
+ status = rpccli_samr_OpenAlias(pipe_cli, ctx,
+ &builtin_handle,
+ SAMR_ALIAS_ACCESS_LOOKUP_INFO,
+ user_rids.ids[0],
+ &alias_handle);
+ if (NT_STATUS_IS_OK(status)) {
+ rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
+ goto query_alias;
+ }
+ }
+
+ rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
+
+ status = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_CREATE_ALIAS |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ status = rpccli_samr_LookupNames(pipe_cli, ctx,
+ &domain_handle,
+ 1,
+ &lsa_account_name,
+ &user_rids,
+ &name_types);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ status = rpccli_samr_OpenAlias(pipe_cli, ctx,
+ &domain_handle,
+ SAMR_ALIAS_ACCESS_LOOKUP_INFO,
+ user_rids.ids[0],
+ &alias_handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
+
+ query_alias:
+ status = rpccli_samr_QueryAliasInfo(pipe_cli, ctx,
+ &alias_handle,
+ ALIASINFOALL,
+ &alias_info);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ werr = map_alias_info_to_buffer(ctx, &alias_info->all,
+ r->in.level, r->out.buf);
+
+ done:
+ if (!cli) {
+ return werr;
+ }
+
+ if (is_valid_policy_hnd(&alias_handle)) {
+ rpccli_samr_Close(pipe_cli, ctx, &alias_handle);
+ }
+ if (is_valid_policy_hnd(&domain_handle)) {
+ rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
+ }
+ if (is_valid_policy_hnd(&builtin_handle)) {
+ rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
+ }
+ if (is_valid_policy_hnd(&connect_handle)) {
+ rpccli_samr_Close(pipe_cli, ctx, &connect_handle);
+ }
+
+ return werr;
}
/****************************************************************
@@ -363,5 +549,5 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
WERROR NetLocalGroupGetInfo_l(struct libnetapi_ctx *ctx,
struct NetLocalGroupGetInfo *r)
{
- return WERR_NOT_SUPPORTED;
+ return NetLocalGroupGetInfo_r(ctx, r);
}