[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-3321-gd282e5e

Günther Deschner gd at samba.org
Fri Jul 18 15:18:55 GMT 2008


The branch, v3-3-test has been updated
       via  d282e5eca298c4c45cbe91a93350273d1417a050 (commit)
       via  62cdd66a7e91b986f76f94935f04375591671893 (commit)
       via  7260fb4dbae556b116e385bdcc240416e8a8cbd2 (commit)
       via  84962bf50d2c3265c0134481f24f6fa34f1dfc99 (commit)
       via  60e646b5b5d8bce5c7a6f8692bba7125075656e2 (commit)
       via  ec5c0153347f3ea37fa3ad65800c0fc408ac8509 (commit)
      from  22bd3d401e47ffedf1169c0c74a329e9fdcac561 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit d282e5eca298c4c45cbe91a93350273d1417a050
Author: Günther Deschner <gd at samba.org>
Date:   Thu Jul 17 22:45:09 2008 +0200

    netapi: fill in NetUserGetInfo_r().
    
    Guenther

commit 62cdd66a7e91b986f76f94935f04375591671893
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jul 16 10:59:53 2008 +0200

    netapi: add NetUserGetInfo example code.
    
    Guenther

commit 7260fb4dbae556b116e385bdcc240416e8a8cbd2
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jul 16 10:50:26 2008 +0200

    netapi: add NetUserGetInfo to public headers.
    
    Guenther

commit 84962bf50d2c3265c0134481f24f6fa34f1dfc99
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jul 16 10:47:38 2008 +0200

    netapi: add skeleton for NetUserGetInfo().
    
    Guenther

commit 60e646b5b5d8bce5c7a6f8692bba7125075656e2
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jul 16 10:45:31 2008 +0200

    re-run make idl.
    
    Guenther

commit ec5c0153347f3ea37fa3ad65800c0fc408ac8509
Author: Günther Deschner <gd at samba.org>
Date:   Wed Jul 16 10:45:11 2008 +0200

    netapi: add NetUserGetInfo to IDL.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/lib/netapi/examples/Makefile.in             |    6 +
 .../{group/group_getinfo.c => user/user_getinfo.c} |   83 ++++++++------
 source/lib/netapi/libnetapi.c                      |   46 ++++++++
 source/lib/netapi/libnetapi.h                      |    8 ++
 source/lib/netapi/netapi.h                         |   20 +++
 source/lib/netapi/user.c                           |  122 ++++++++++++++++++++
 source/librpc/gen_ndr/libnetapi.h                  |   15 +++
 source/librpc/gen_ndr/ndr_libnetapi.c              |   33 ++++++
 source/librpc/gen_ndr/ndr_libnetapi.h              |   33 +++---
 source/librpc/idl/libnetapi.idl                    |   11 ++
 10 files changed, 330 insertions(+), 47 deletions(-)
 copy source/lib/netapi/examples/{group/group_getinfo.c => user/user_getinfo.c} (51%)


Changeset truncated at 500 lines:

diff --git a/source/lib/netapi/examples/Makefile.in b/source/lib/netapi/examples/Makefile.in
index 4762634..f15b099 100644
--- a/source/lib/netapi/examples/Makefile.in
+++ b/source/lib/netapi/examples/Makefile.in
@@ -27,6 +27,7 @@ PROGS = bin/getdc at EXEEXT@ \
 	bin/user_enum at EXEEXT@ \
 	bin/user_dispinfo at EXEEXT@ \
 	bin/user_chgpwd at EXEEXT@ \
+	bin/user_getinfo at EXEEXT@ \
 	bin/group_add at EXEEXT@ \
 	bin/group_del at EXEEXT@ \
 	bin/group_enum at EXEEXT@ \
@@ -77,6 +78,7 @@ USERDEL_OBJ = user/user_del.o $(CMDLINE_OBJ)
 USERENUM_OBJ = user/user_enum.o $(CMDLINE_OBJ)
 USERDISPINFO_OBJ = user/user_dispinfo.o $(CMDLINE_OBJ)
 USERCHGPWD_OBJ = user/user_chgpwd.o $(CMDLINE_OBJ)
+USERGETINFO_OBJ = user/user_getinfo.o $(CMDLINE_OBJ)
 GROUPADD_OBJ = group/group_add.o $(CMDLINE_OBJ)
 GROUPDEL_OBJ = group/group_del.o $(CMDLINE_OBJ)
 GROUPENUM_OBJ = group/group_enum.o $(CMDLINE_OBJ)
@@ -130,6 +132,10 @@ bin/user_chgpwd at EXEEXT@: $(BINARY_PREREQS) $(USERCHGPWD_OBJ)
 	@echo Linking $@
 	@$(CC) $(FLAGS) -o $@ $(USERCHGPWD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
 
+bin/user_getinfo at EXEEXT@: $(BINARY_PREREQS) $(USERGETINFO_OBJ)
+	@echo Linking $@
+	@$(CC) $(FLAGS) -o $@ $(USERGETINFO_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
 bin/group_add at EXEEXT@: $(BINARY_PREREQS) $(GROUPADD_OBJ)
 	@echo Linking $@
 	@$(CC) $(FLAGS) -o $@ $(GROUPADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
diff --git a/source/lib/netapi/examples/group/group_getinfo.c b/source/lib/netapi/examples/user/user_getinfo.c
similarity index 51%
copy from source/lib/netapi/examples/group/group_getinfo.c
copy to source/lib/netapi/examples/user/user_getinfo.c
index 2e5b793..19234d0 100644
--- a/source/lib/netapi/examples/group/group_getinfo.c
+++ b/source/lib/netapi/examples/user/user_getinfo.c
@@ -1,6 +1,6 @@
 /*
  *  Unix SMB/CIFS implementation.
- *  NetGroupGetInfo query
+ *  NetUserGetInfo query
  *  Copyright (C) Guenther Deschner 2008
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -32,15 +32,17 @@ int main(int argc, const char **argv)
 	NET_API_STATUS status;
 	struct libnetapi_ctx *ctx = NULL;
 	const char *hostname = NULL;
-	const char *groupname = NULL;
+	const char *username = NULL;
 	uint8_t *buffer = NULL;
 	uint32_t level = 0;
-	struct GROUP_INFO_0 *g0;
-	struct GROUP_INFO_1 *g1;
-	struct GROUP_INFO_2 *g2;
-	struct GROUP_INFO_3 *g3;
 	char *sid_str = NULL;
 
+	struct USER_INFO_0 *u0;
+	struct USER_INFO_1 *u1;
+	struct USER_INFO_10 *u10;
+	struct USER_INFO_20 *u20;
+	struct USER_INFO_23 *u23;
+
 	poptContext pc;
 	int opt;
 
@@ -55,9 +57,9 @@ int main(int argc, const char **argv)
 		return status;
 	}
 
-	pc = poptGetContext("group_getinfo", argc, argv, long_options, 0);
+	pc = poptGetContext("user_getinfo", argc, argv, long_options, 0);
 
-	poptSetOtherOptionHelp(pc, "hostname groupname level");
+	poptSetOtherOptionHelp(pc, "hostname username level");
 	while((opt = poptGetNextOpt(pc)) != -1) {
 	}
 
@@ -71,51 +73,66 @@ int main(int argc, const char **argv)
 		poptPrintHelp(pc, stderr, 0);
 		goto out;
 	}
-	groupname = poptGetArg(pc);
+	username = poptGetArg(pc);
 
 	if (poptPeekArg(pc)) {
 		level = atoi(poptGetArg(pc));
 	}
 
-	/* NetGroupGetInfo */
+	/* NetUserGetInfo */
 
-	status = NetGroupGetInfo(hostname,
-				 groupname,
-				 level,
-				 &buffer);
+	status = NetUserGetInfo(hostname,
+				username,
+				level,
+				&buffer);
 	if (status != 0) {
-		printf("NetGroupGetInfo failed with: %s\n",
+		printf("NetUserGetInfo failed with: %s\n",
 			libnetapi_get_error_string(ctx, status));
 		goto out;
 	}
 
 	switch (level) {
 		case 0:
-			g0 = (struct GROUP_INFO_0 *)buffer;
-			printf("name: %s\n", g0->grpi0_name);
+			u0 = (struct USER_INFO_0 *)buffer;
+			printf("name: %s\n", u0->usri0_name);
 			break;
 		case 1:
-			g1 = (struct GROUP_INFO_1 *)buffer;
-			printf("name: %s\n", g1->grpi1_name);
-			printf("comment: %s\n", g1->grpi1_comment);
+			u1 = (struct USER_INFO_1 *)buffer;
+			printf("name: %s\n", u1->usri1_name);
+			printf("password: %s\n", u1->usri1_password);
+			printf("password_age: %d\n", u1->usri1_password_age);
+			printf("priv: %d\n", u1->usri1_priv);
+			printf("homedir: %s\n", u1->usri1_home_dir);
+			printf("comment: %s\n", u1->usri1_comment);
+			printf("flags: 0x%08x\n", u1->usri1_flags);
+			printf("script: %s\n", u1->usri1_script_path);
+			break;
+		case 10:
+			u10 = (struct USER_INFO_10 *)buffer;
+			printf("name: %s\n", u10->usri10_name);
+			printf("comment: %s\n", u10->usri10_comment);
+			printf("usr_comment: %s\n", u10->usri10_usr_comment);
+			printf("full_name: %s\n", u10->usri10_full_name);
 			break;
-		case 2:
-			g2 = (struct GROUP_INFO_2 *)buffer;
-			printf("name: %s\n", g2->grpi2_name);
-			printf("comment: %s\n", g2->grpi2_comment);
-			printf("group_id: %d\n", g2->grpi2_group_id);
-			printf("attributes: %d\n", g2->grpi2_attributes);
+		case 20:
+			u20 = (struct USER_INFO_20 *)buffer;
+			printf("name: %s\n", u20->usri20_name);
+			printf("comment: %s\n", u20->usri20_comment);
+			printf("flags: 0x%08x\n", u20->usri20_flags);
+			printf("rid: %d\n", u20->usri20_user_id);
 			break;
-		case 3:
-			g3 = (struct GROUP_INFO_3 *)buffer;
-			printf("name: %s\n", g3->grpi3_name);
-			printf("comment: %s\n", g3->grpi3_comment);
-			if (ConvertSidToStringSid(g3->grpi3_group_sid,
+		case 23:
+			u23 = (struct USER_INFO_23 *)buffer;
+			printf("name: %s\n", u23->usri23_name);
+			printf("comment: %s\n", u23->usri23_comment);
+			printf("flags: 0x%08x\n", u23->usri23_flags);
+			if (ConvertSidToStringSid(u23->usri23_user_sid,
 						  &sid_str)) {
-				printf("group_sid: %s\n", sid_str);
+				printf("user_sid: %s\n", sid_str);
 				free(sid_str);
 			}
-			printf("attributes: %d\n", g3->grpi3_attributes);
+			break;
+		default:
 			break;
 	}
 
diff --git a/source/lib/netapi/libnetapi.c b/source/lib/netapi/libnetapi.c
index 0953de6..8013c74 100644
--- a/source/lib/netapi/libnetapi.c
+++ b/source/lib/netapi/libnetapi.c
@@ -632,6 +632,52 @@ NET_API_STATUS NetUserChangePassword(const char * domain_name /* [in] */,
 }
 
 /****************************************************************
+ NetUserGetInfo
+****************************************************************/
+
+NET_API_STATUS NetUserGetInfo(const char * server_name /* [in] */,
+			      const char * user_name /* [in] */,
+			      uint32_t level /* [in] */,
+			      uint8_t **buffer /* [out] [ref] */)
+{
+	struct NetUserGetInfo r;
+	struct libnetapi_ctx *ctx = NULL;
+	NET_API_STATUS status;
+	WERROR werr;
+
+	status = libnetapi_getctx(&ctx);
+	if (status != 0) {
+		return status;
+	}
+
+	/* In parameters */
+	r.in.server_name = server_name;
+	r.in.user_name = user_name;
+	r.in.level = level;
+
+	/* Out parameters */
+	r.out.buffer = buffer;
+
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_IN_DEBUG(NetUserGetInfo, &r);
+	}
+
+	if (LIBNETAPI_LOCAL_SERVER(server_name)) {
+		werr = NetUserGetInfo_l(ctx, &r);
+	} else {
+		werr = NetUserGetInfo_r(ctx, &r);
+	}
+
+	r.out.result = W_ERROR_V(werr);
+
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_OUT_DEBUG(NetUserGetInfo, &r);
+	}
+
+	return r.out.result;
+}
+
+/****************************************************************
  NetQueryDisplayInformation
 ****************************************************************/
 
diff --git a/source/lib/netapi/libnetapi.h b/source/lib/netapi/libnetapi.h
index a6c8e84..349c3c1 100644
--- a/source/lib/netapi/libnetapi.h
+++ b/source/lib/netapi/libnetapi.h
@@ -108,6 +108,14 @@ WERROR NetUserChangePassword_r(struct libnetapi_ctx *ctx,
 			       struct NetUserChangePassword *r);
 WERROR NetUserChangePassword_l(struct libnetapi_ctx *ctx,
 			       struct NetUserChangePassword *r);
+NET_API_STATUS NetUserGetInfo(const char * server_name /* [in] */,
+			      const char * user_name /* [in] */,
+			      uint32_t level /* [in] */,
+			      uint8_t **buffer /* [out] [ref] */);
+WERROR NetUserGetInfo_r(struct libnetapi_ctx *ctx,
+			struct NetUserGetInfo *r);
+WERROR NetUserGetInfo_l(struct libnetapi_ctx *ctx,
+			struct NetUserGetInfo *r);
 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
 					  uint32_t level /* [in] */,
 					  uint32_t idx /* [in] */,
diff --git a/source/lib/netapi/netapi.h b/source/lib/netapi/netapi.h
index 2260c28..95ecbe3 100644
--- a/source/lib/netapi/netapi.h
+++ b/source/lib/netapi/netapi.h
@@ -688,6 +688,26 @@ NET_API_STATUS NetUserChangePassword(const char * domain_name /* [in] */,
 
 /************************************************************//**
  *
+ * NetUserGetInfo
+ *
+ * @brief Get User Information
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] user_name The name of the user that is going to be queried
+ * @param[in] level The level defining the requested USER_INFO_X structure
+ * @param[out] buffer The buffer containing a USER_INFO_X structure
+ * @return NET_API_STATUS
+ *
+ * example user/user_getinfo.c
+ ***************************************************************/
+
+NET_API_STATUS NetUserGetInfo(const char * server_name /* [in] */,
+			      const char * user_name /* [in] */,
+			      uint32_t level /* [in] */,
+			      uint8_t **buffer /* [out] [ref] */);
+
+/************************************************************//**
+ *
  * NetQueryDisplayInformation
  *
  * @brief Enumerate accounts on a server
diff --git a/source/lib/netapi/user.c b/source/lib/netapi/user.c
index 8b1287e..b318aa6 100644
--- a/source/lib/netapi/user.c
+++ b/source/lib/netapi/user.c
@@ -1082,3 +1082,125 @@ WERROR NetUserChangePassword_l(struct libnetapi_ctx *ctx,
 {
 	return WERR_NOT_SUPPORTED;
 }
+
+/****************************************************************
+****************************************************************/
+
+WERROR NetUserGetInfo_r(struct libnetapi_ctx *ctx,
+			struct NetUserGetInfo *r)
+{
+	struct cli_state *cli = NULL;
+	struct rpc_pipe_client *pipe_cli = NULL;
+	NTSTATUS status;
+	WERROR werr;
+
+	struct policy_handle connect_handle, domain_handle, builtin_handle, user_handle;
+	struct lsa_String lsa_account_name;
+	struct dom_sid2 *domain_sid = NULL;
+	struct samr_Ids user_rids, name_types;
+	uint32_t num_entries = 0;
+
+	ZERO_STRUCT(connect_handle);
+	ZERO_STRUCT(domain_handle);
+	ZERO_STRUCT(builtin_handle);
+	ZERO_STRUCT(user_handle);
+
+	if (!r->out.buffer) {
+		return WERR_INVALID_PARAM;
+	}
+
+	switch (r->in.level) {
+		case 0:
+		/* case 1: */
+		case 10:
+		case 20:
+		case 23:
+			break;
+		default:
+			werr = WERR_NOT_SUPPORTED;
+			goto done;
+	}
+
+	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;
+	}
+
+	werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+					  SAMR_ACCESS_ENUM_DOMAINS |
+					  SAMR_ACCESS_OPEN_DOMAIN,
+					  SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+					  &connect_handle,
+					  &domain_handle,
+					  &domain_sid);
+	if (!W_ERROR_IS_OK(werr)) {
+		goto done;
+	}
+
+	werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
+						  SAMR_ACCESS_ENUM_DOMAINS |
+						  SAMR_ACCESS_OPEN_DOMAIN,
+						  SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT |
+						  SAMR_DOMAIN_ACCESS_LOOKUP_ALIAS,
+						  &connect_handle,
+						  &builtin_handle);
+	if (!W_ERROR_IS_OK(werr)) {
+		goto done;
+	}
+
+	init_lsa_String(&lsa_account_name, r->in.user_name);
+
+	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 = libnetapi_samr_lookup_user_map_USER_INFO(ctx, pipe_cli,
+							  domain_sid,
+							  &domain_handle,
+							  &builtin_handle,
+							  r->in.user_name,
+							  user_rids.ids[0],
+							  r->in.level,
+							  r->out.buffer,
+							  &num_entries);
+	if (!NT_STATUS_IS_OK(status)) {
+		werr = ntstatus_to_werror(status);
+		goto done;
+	}
+
+ done:
+	if (!cli) {
+		return werr;
+	}
+
+	if (is_valid_policy_hnd(&user_handle)) {
+		rpccli_samr_Close(pipe_cli, ctx, &user_handle);
+	}
+
+	libnetapi_samr_close_domain_handle(ctx, &domain_handle);
+	libnetapi_samr_close_connect_handle(ctx, &connect_handle);
+
+	return werr;
+}
+
+/****************************************************************
+****************************************************************/
+
+WERROR NetUserGetInfo_l(struct libnetapi_ctx *ctx,
+			struct NetUserGetInfo *r)
+{
+	return WERR_NOT_SUPPORTED;
+}
+
diff --git a/source/librpc/gen_ndr/libnetapi.h b/source/librpc/gen_ndr/libnetapi.h
index e5c03b6..1a6898c 100644
--- a/source/librpc/gen_ndr/libnetapi.h
+++ b/source/librpc/gen_ndr/libnetapi.h
@@ -489,6 +489,21 @@ struct NetUserChangePassword {
 };
 
 
+struct NetUserGetInfo {
+	struct {
+		const char * server_name;
+		const char * user_name;
+		uint32_t level;
+	} in;
+
+	struct {
+		uint8_t **buffer;/* [ref] */
+		enum NET_API_STATUS result;
+	} out;
+
+};
+
+
 struct NetQueryDisplayInformation {
 	struct {
 		const char * server_name;/* [unique] */
diff --git a/source/librpc/gen_ndr/ndr_libnetapi.c b/source/librpc/gen_ndr/ndr_libnetapi.c
index 246b5fb..42d2163 100644
--- a/source/librpc/gen_ndr/ndr_libnetapi.c
+++ b/source/librpc/gen_ndr/ndr_libnetapi.c
@@ -1619,6 +1619,39 @@ _PUBLIC_ void ndr_print_NetUserChangePassword(struct ndr_print *ndr, const char
 	ndr->depth--;
 }
 
+_PUBLIC_ void ndr_print_NetUserGetInfo(struct ndr_print *ndr, const char *name, int flags, const struct NetUserGetInfo *r)
+{
+	ndr_print_struct(ndr, name, "NetUserGetInfo");
+	ndr->depth++;
+	if (flags & NDR_SET_VALUES) {
+		ndr->flags |= LIBNDR_PRINT_SET_VALUES;
+	}
+	if (flags & NDR_IN) {
+		ndr_print_struct(ndr, "in", "NetUserGetInfo");
+		ndr->depth++;
+		ndr_print_string(ndr, "server_name", r->in.server_name);
+		ndr_print_string(ndr, "user_name", r->in.user_name);
+		ndr_print_uint32(ndr, "level", r->in.level);
+		ndr->depth--;
+	}
+	if (flags & NDR_OUT) {
+		ndr_print_struct(ndr, "out", "NetUserGetInfo");
+		ndr->depth++;
+		ndr_print_ptr(ndr, "buffer", r->out.buffer);
+		ndr->depth++;
+		ndr_print_ptr(ndr, "buffer", *r->out.buffer);
+		ndr->depth++;
+		if (*r->out.buffer) {
+			ndr_print_uint8(ndr, "buffer", **r->out.buffer);
+		}
+		ndr->depth--;
+		ndr->depth--;
+		ndr_print_NET_API_STATUS(ndr, "result", r->out.result);
+		ndr->depth--;
+	}
+	ndr->depth--;
+}
+
 _PUBLIC_ void ndr_print_NetQueryDisplayInformation(struct ndr_print *ndr, const char *name, int flags, const struct NetQueryDisplayInformation *r)
 {
 	ndr_print_struct(ndr, name, "NetQueryDisplayInformation");
diff --git a/source/librpc/gen_ndr/ndr_libnetapi.h b/source/librpc/gen_ndr/ndr_libnetapi.h
index afb2cea..29a8bb6 100644
--- a/source/librpc/gen_ndr/ndr_libnetapi.h
+++ b/source/librpc/gen_ndr/ndr_libnetapi.h
@@ -32,33 +32,35 @@
 
 #define NDR_NETUSERCHANGEPASSWORD (0x0c)
 
-#define NDR_NETQUERYDISPLAYINFORMATION (0x0d)
+#define NDR_NETUSERGETINFO (0x0d)
 
-#define NDR_NETGROUPADD (0x0e)
+#define NDR_NETQUERYDISPLAYINFORMATION (0x0e)
 
-#define NDR_NETGROUPDEL (0x0f)
+#define NDR_NETGROUPADD (0x0f)
 
-#define NDR_NETGROUPENUM (0x10)
+#define NDR_NETGROUPDEL (0x10)
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list