diff options
author | Wilco Baan Hofman <wilco@baanhofman.nl> | 2010-04-23 18:10:43 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-06-20 17:19:11 +0200 |
commit | f0353fddde4a0b8aab448db779cc2c1cc419b4a0 (patch) | |
tree | 7d09196ad2421a12cda2f93aff5b72e7c563bafb /source4/lib | |
parent | 40d71815072b5258cbe3ed0f1de62be68625e25e (diff) | |
download | samba-f0353fddde4a0b8aab448db779cc2c1cc419b4a0.tar.gz samba-f0353fddde4a0b8aab448db779cc2c1cc419b4a0.tar.bz2 samba-f0353fddde4a0b8aab448db779cc2c1cc419b4a0.zip |
Changed add_gplink to set_gplink, so we can change gPLink options as well.
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/policy/gp_ldap.c | 21 | ||||
-rw-r--r-- | source4/lib/policy/policy.h | 2 |
2 files changed, 16 insertions, 7 deletions
diff --git a/source4/lib/policy/gp_ldap.c b/source4/lib/policy/gp_ldap.c index 8f44adcc6d..e1faed1362 100644 --- a/source4/lib/policy/gp_ldap.c +++ b/source4/lib/policy/gp_ldap.c @@ -541,7 +541,7 @@ NTSTATUS gp_list_gpos(struct gp_context *gp_ctx, struct security_token *token, c return NT_STATUS_OK; } -NTSTATUS gp_add_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_link *gplink) +NTSTATUS gp_set_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_link *gplink) { TALLOC_CTX *mem_ctx; struct ldb_result *result; @@ -550,6 +550,7 @@ NTSTATUS gp_add_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_ const char *attrs[] = { "gPLink", NULL }; const char *gplink_str; int rv; + char *start; /* Create a forked memory context, as a base for everything here */ mem_ctx = talloc_new(gp_ctx); @@ -570,14 +571,22 @@ NTSTATUS gp_add_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_ gplink_str = ldb_msg_find_attr_as_string(result->msgs[0], "gPLink", ""); - if (strstr(gplink_str, gplink->dn) != NULL) { - talloc_free(mem_ctx); - return NT_STATUS_OBJECT_NAME_COLLISION; + /* If this GPO link already exists, alter the options, else add it */ + if ((start = strcasestr(gplink_str, gplink->dn)) != NULL) { + start += strlen(gplink->dn); + *start = '\0'; + start++; + while (*start != ']' && *start != '\0') { + start++; + } + gplink_str = talloc_asprintf(mem_ctx, "%s;%d%s\n", gplink_str, gplink->options, start); + + } else { + /* Prepend the new GPO link to the string. This list is backwards in priority. */ + gplink_str = talloc_asprintf(mem_ctx, "[LDAP://%s;%d]%s", gplink->dn, gplink->options, gplink_str); } - /* Prepend the new GPO link to the string. This list is backwards in priority. */ - gplink_str = talloc_asprintf(mem_ctx, "[LDAP://%s;%d]%s", gplink->dn, gplink->options, gplink_str); msg = ldb_msg_new(mem_ctx); msg->dn = dn; diff --git a/source4/lib/policy/policy.h b/source4/lib/policy/policy.h index 0f78b0f8b8..05a2815989 100644 --- a/source4/lib/policy/policy.h +++ b/source4/lib/policy/policy.h @@ -80,7 +80,7 @@ NTSTATUS gp_del_gpo(struct gp_context *gp_ctx, const char *dn_str); NTSTATUS gp_get_gplink_options(TALLOC_CTX *mem_ctx, uint32_t flags, const char ***ret); NTSTATUS gp_get_gpo_flags(TALLOC_CTX *mem_ctx, uint32_t flags, const char ***ret); -NTSTATUS gp_add_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_link *gplink); +NTSTATUS gp_set_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_link *gplink); NTSTATUS gp_del_gplink(struct gp_context *gp_ctx, const char *dn_str, const char *gp_dn); #endif |