summaryrefslogtreecommitdiff
path: root/source4/utils
diff options
context:
space:
mode:
authorWilco Baan Hofman <wilco@baanhofman.nl>2010-04-23 17:31:21 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-06-20 17:19:10 +0200
commit40d71815072b5258cbe3ed0f1de62be68625e25e (patch)
tree7829193a0efbaedbd616cdf81316f6c5b25714e1 /source4/utils
parenta1fceac844a0a7690ab985fa08e6a08127e770bf (diff)
downloadsamba-40d71815072b5258cbe3ed0f1de62be68625e25e.tar.gz
samba-40d71815072b5258cbe3ed0f1de62be68625e25e.tar.bz2
samba-40d71815072b5258cbe3ed0f1de62be68625e25e.zip
Add add gPLink function and corresponding net gpo linkadd call.
Also added some definitions for future functions in policy.h Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'source4/utils')
-rw-r--r--source4/utils/net/net_gpo.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/source4/utils/net/net_gpo.c b/source4/utils/net/net_gpo.c
index 6301fc2129..e828899cac 100644
--- a/source4/utils/net/net_gpo.c
+++ b/source4/utils/net/net_gpo.c
@@ -272,14 +272,64 @@ static int net_gpo_list(struct net_context *ctx, int argc, const char **argv)
return 0;
}
+static int net_gpo_link_add_usage(struct net_context *ctx, int argc, const char **argv)
+{
+ d_printf("Syntax: net gpo linkadd <container> <gpo> ['disable'] ['enforce'] [options]\n");
+ d_printf("For a list of available options, please type net gpo linkadd --help\n");
+ return 0;
+}
+
+static int net_gpo_link_add(struct net_context *ctx, int argc, const char **argv)
+{
+ struct gp_link *gplink = talloc_zero(ctx, struct gp_link);
+ struct gp_context *gp_ctx;
+ unsigned int i;
+ NTSTATUS status;
+
+ if (argc < 2) {
+ return net_gpo_link_add_usage(ctx, argc, argv);
+ }
+
+ if (argc >= 3) {
+ for (i = 2; i < argc; i++) {
+ if (strcmp(argv[i], "disable") == 0) {
+ gplink->options |= GPLINK_OPT_DISABLE;
+ }
+ if (strcmp(argv[i], "enforce") == 0) {
+ gplink->options |= GPLINK_OPT_ENFORCE;
+ }
+ }
+ }
+ gplink->dn = argv[1];
+
+ status = gp_init(ctx, ctx->lp_ctx, ctx->credentials, ctx->event_ctx, &gp_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Failed to connect to DC's LDAP: %s\n", get_friendly_nt_error_msg(status)));
+ return 1;
+ }
+
+ status = gp_add_gplink(gp_ctx, argv[0], gplink);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Failed to add GPO link to container: %s\n", get_friendly_nt_error_msg(status)));
+ return 1;
+ }
+ d_printf("Added link to container.\n");
+
+ /* Display current links */
+ net_gpo_link_get(ctx, 1, argv);
+
+ talloc_free(gp_ctx);
+ return 0;
+}
+
static const struct net_functable net_gpo_functable[] = {
{ "listall", "List all GPO's on a DC\n", net_gpo_list_all, net_gpo_list_all_usage },
{ "getgpo", "List specificied GPO\n", net_gpo_get_gpo, net_gpo_get_gpo_usage },
{ "linkget", "List gPLink of container\n", net_gpo_link_get, net_gpo_link_get_usage },
-/* { "apply", "Apply GPO to container\n", net_gpo_apply, net_gpo_usage }, */
-// { "linkadd", "Link a GPO to a container\n", net_gpo_link_add, net_gpo_usage },
+ { "linkadd", "Link a GPO to a container\n", net_gpo_link_add, net_gpo_link_add_usage },
/* { "linkdelete", "Delete GPO link from a container\n", net_gpo_link_delete, net_gpo_usage }, */
{ "list", "List all GPO's for a machine/user\n", net_gpo_list, net_gpo_list_usage },
+/* { "apply", "Apply GPO to container\n", net_gpo_apply, net_gpo_usage }, */
// { "refresh", "List all GPO's for machine/user and download them\n", net_gpo_refresh, net_gpo_refresh_usage },
{ NULL, NULL }
};