summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2014-10-02 16:13:18 +0100
committerJeremy Allison <jra@samba.org>2015-01-08 00:18:05 +0100
commita5d383cbd56fdab958334c8e6a19a824941c11c1 (patch)
treedbc5b33685964bcb19061e04d4d741908f47df2f
parenta13e29cc4345d85ab6fe4482119386b87e4e8673 (diff)
downloadsamba-a5d383cbd56fdab958334c8e6a19a824941c11c1.tar.gz
samba-a5d383cbd56fdab958334c8e6a19a824941c11c1.tar.xz
samba-a5d383cbd56fdab958334c8e6a19a824941c11c1.zip
allow net ads join accept new osServicePack parameter
osServicePack paramater allows the default behaviour ( which is to use the samba version string as the operatingSystemServicePack attribute ) to be overridden Additionally make sure if blank string is passed that it is treated as attribute deletion. This is necessary as values for the os attributes are eventually passed to ads_modlist_add if the value is "" then the attempt to add this attribute fails in the underlying ldap 'ldap_modfiy_ext_s' function. In this case we need to pass NULL as the value to force deletion of the ldap attribute Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Jan 8 00:18:05 CET 2015 on sn-devel-104
-rw-r--r--source3/libnet/libnet_join.c15
-rw-r--r--source3/librpc/idl/libnet_join.idl1
-rw-r--r--source3/utils/net_ads.c12
3 files changed, 26 insertions, 2 deletions
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index dd87c6d425..c5a61fe73c 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -574,8 +574,19 @@ static ADS_STATUS libnet_join_set_os_attributes(TALLOC_CTX *mem_ctx,
return ADS_ERROR(LDAP_NO_MEMORY);
}
- os_sp = talloc_asprintf(mem_ctx, "Samba %s", samba_version_string());
- if (!os_sp) {
+ if (r->in.os_servicepack) {
+ /*
+ * if blank string then leave os_sp equal to NULL to force
+ * attribute delete (LDAP_MOD_DELETE)
+ */
+ if (!strequal(r->in.os_servicepack,"")) {
+ os_sp = talloc_strdup(mem_ctx, r->in.os_servicepack);
+ }
+ } else {
+ os_sp = talloc_asprintf(mem_ctx, "Samba %s",
+ samba_version_string());
+ }
+ if (!os_sp && !strequal(r->in.os_servicepack,"")) {
return ADS_ERROR(LDAP_NO_MEMORY);
}
diff --git a/source3/librpc/idl/libnet_join.idl b/source3/librpc/idl/libnet_join.idl
index ac0a35005b..cb2d9e4dcd 100644
--- a/source3/librpc/idl/libnet_join.idl
+++ b/source3/librpc/idl/libnet_join.idl
@@ -27,6 +27,7 @@ interface libnetjoin
[in] wkssvc_joinflags join_flags,
[in] string os_version,
[in] string os_name,
+ [in] string os_servicepack,
[in] boolean8 create_upn,
[in] string upn,
[in] boolean8 modify_config,
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index ba500b50b6..b0e7112cfd 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1329,6 +1329,9 @@ static int net_ads_join_usage(struct net_context *c, int argc, const char **argv
" Also, the operatingSystemService attribute is also set when along with\n"
" the two other attributes.\n"));
+ d_printf(_(" osServicePack=string Set the operatingSystemServicePack "
+ "attribute during the join. Note: if not specified then by "
+ "default the samba version string is used instead.\n"));
return -1;
}
@@ -1434,6 +1437,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
int i;
const char *os_name = NULL;
const char *os_version = NULL;
+ const char *os_servicepack = NULL;
bool modify_config = lp_config_backend_is_registry();
if (c->display_usage)
@@ -1491,6 +1495,13 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
goto fail;
}
}
+ else if ( !strncasecmp_m(argv[i], "osServicePack", strlen("osServicePack")) ) {
+ if ( (os_servicepack = get_string_param(argv[i])) == NULL ) {
+ d_fprintf(stderr, _("Please supply a valid servicepack identifier.\n"));
+ werr = WERR_INVALID_PARAM;
+ goto fail;
+ }
+ }
else if ( !strncasecmp_m(argv[i], "machinepass", strlen("machinepass")) ) {
if ( (machine_password = get_string_param(argv[i])) == NULL ) {
d_fprintf(stderr, _("Please supply a valid password to set as trust account password.\n"));
@@ -1524,6 +1535,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
r->in.account_ou = create_in_ou;
r->in.os_name = os_name;
r->in.os_version = os_version;
+ r->in.os_servicepack = os_servicepack;
r->in.dc_name = c->opt_host;
r->in.admin_account = c->opt_user_name;
r->in.admin_password = net_prompt_pass(c, c->opt_user_name);