diff options
author | Günther Deschner <gd@samba.org> | 2007-12-19 13:52:51 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2007-12-21 15:29:11 +0100 |
commit | 2bed9564dbe4fc3bc86d6ba231c5f2ecce468b5a (patch) | |
tree | 2a2382296ddadaaed46dff4cab497e1c2460a930 /source3/lib/netapi | |
parent | af08d8be3063ada42637a4ae7437499b03457de2 (diff) | |
download | samba-2bed9564dbe4fc3bc86d6ba231c5f2ecce468b5a.tar.gz samba-2bed9564dbe4fc3bc86d6ba231c5f2ecce468b5a.tar.bz2 samba-2bed9564dbe4fc3bc86d6ba231c5f2ecce468b5a.zip |
Split out local and remote paths for NetGetJoinInformation.
Guenther
(This used to be commit d1e4f9dd5cde79f915e3e0f652621d966aa850e8)
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/joindomain.c | 92 |
1 files changed, 52 insertions, 40 deletions
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index 2cc93e2545..0c8d645db9 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -384,50 +384,16 @@ NET_API_STATUS NetUnjoinDomain(const char *server_name, return 0; } - -WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx, - const char *server_name, - const char **name_buffer, - uint16_t *name_type) +static WERROR NetGetJoinInformationRemote(struct libnetapi_ctx *ctx, + const char *server_name, + const char **name_buffer, + uint16_t *name_type) { - TALLOC_CTX *mem_ctx = NULL; struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - mem_ctx = talloc_init("NetGetJoinInformation"); - if (!mem_ctx) { - werr = WERR_NOMEM; - goto done; - } - - if (!server_name || is_myname_or_ipaddr(server_name)) { - if ((lp_security() == SEC_ADS) && lp_realm()) { - *name_buffer = SMB_STRDUP(lp_realm()); - } else { - *name_buffer = SMB_STRDUP(lp_workgroup()); - } - if (!*name_buffer) { - werr = WERR_NOMEM; - goto done; - } - switch (lp_server_role()) { - case ROLE_DOMAIN_MEMBER: - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - *name_type = NetSetupDomainName; - break; - case ROLE_STANDALONE: - default: - *name_type = NetSetupWorkgroupName; - break; - } - - werr = WERR_OK; - goto done; - } - status = cli_full_connection(&cli, NULL, server_name, NULL, 0, "IPC$", "IPC", @@ -448,7 +414,7 @@ WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx, goto done; }; - status = rpccli_wkssvc_NetrGetJoinInformation(pipe_cli, mem_ctx, + status = rpccli_wkssvc_NetrGetJoinInformation(pipe_cli, ctx, server_name, name_buffer, (enum wkssvc_NetJoinStatus *)name_type, @@ -462,11 +428,57 @@ WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx, if (cli) { cli_shutdown(cli); } - TALLOC_FREE(mem_ctx); return werr; } +static WERROR NetGetJoinInformationLocal(struct libnetapi_ctx *ctx, + const char *server_name, + const char **name_buffer, + uint16_t *name_type) +{ + if ((lp_security() == SEC_ADS) && lp_realm()) { + *name_buffer = SMB_STRDUP(lp_realm()); + } else { + *name_buffer = SMB_STRDUP(lp_workgroup()); + } + if (!*name_buffer) { + return WERR_NOMEM; + } + + switch (lp_server_role()) { + case ROLE_DOMAIN_MEMBER: + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + *name_type = NetSetupDomainName; + break; + case ROLE_STANDALONE: + default: + *name_type = NetSetupWorkgroupName; + break; + } + + return WERR_OK; +} + +WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx, + const char *server_name, + const char **name_buffer, + uint16_t *name_type) +{ + if (!server_name || is_myname_or_ipaddr(server_name)) { + return NetGetJoinInformationLocal(ctx, + server_name, + name_buffer, + name_type); + } + + return NetGetJoinInformationRemote(ctx, + server_name, + name_buffer, + name_type); +} + NET_API_STATUS NetGetJoinInformation(const char *server_name, const char **name_buffer, uint16_t *name_type) |