summaryrefslogtreecommitdiff
path: root/source3/rpc_client/cli_netlogon.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-11-13 11:38:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:24 -0500
commit32cf16f3cfaf52414c324c0a333ff29cb9a326aa (patch)
tree62fa857b878289aeddbe6ac8ba0dc868c56ea9ce /source3/rpc_client/cli_netlogon.c
parent789bed878aa94edf22521c6c1946d3ab73462516 (diff)
downloadsamba-32cf16f3cfaf52414c324c0a333ff29cb9a326aa.tar.gz
samba-32cf16f3cfaf52414c324c0a333ff29cb9a326aa.tar.bz2
samba-32cf16f3cfaf52414c324c0a333ff29cb9a326aa.zip
r11706: Implement dsr_getdcname client code. It's handy: It not only gives you the IP
address but also the fqdn of the remote dc and site info. Volker (This used to be commit 62d01ce7e6c14971084c208ab61f379cb172cb22)
Diffstat (limited to 'source3/rpc_client/cli_netlogon.c')
-rw-r--r--source3/rpc_client/cli_netlogon.c123
1 files changed, 123 insertions, 0 deletions
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index af0062f2b3..f12f7d09fa 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -417,6 +417,129 @@ NTSTATUS rpccli_netlogon_getdcname(struct rpc_pipe_client *cli,
return result;
}
+/* Dsr_GetDCName */
+
+WERROR rpccli_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *server_name,
+ const char *domain_name,
+ struct uuid *domain_guid,
+ struct uuid *site_guid,
+ uint32_t flags,
+ char **dc_unc, char **dc_address,
+ int32 *dc_address_type,
+ struct uuid *domain_guid_out,
+ char **domain_name_out,
+ char **forest_name,
+ uint32 *dc_flags,
+ char **dc_site_name,
+ char **client_site_name)
+{
+ prs_struct qbuf, rbuf;
+ NET_Q_DSR_GETDCNAME q;
+ NET_R_DSR_GETDCNAME r;
+ char *tmp_str;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialize input parameters */
+
+ tmp_str = talloc_asprintf(mem_ctx, "\\\\%s", server_name);
+ if (tmp_str == NULL) {
+ return WERR_NOMEM;
+ }
+
+ init_net_q_dsr_getdcname(&q, tmp_str, domain_name, domain_guid,
+ site_guid, flags);
+
+ /* Marshall data and send request */
+
+ CLI_DO_RPC_WERR(cli, mem_ctx, PI_NETLOGON, NET_DSR_GETDCNAME,
+ q, r,
+ qbuf, rbuf,
+ net_io_q_dsr_getdcname,
+ net_io_r_dsr_getdcname,
+ WERR_GENERAL_FAILURE);
+
+ if (!W_ERROR_IS_OK(r.result)) {
+ return r.result;
+ }
+
+ if (dc_unc != NULL) {
+ char *tmp;
+ if (rpcstr_pull_unistr2_talloc(mem_ctx, &tmp,
+ &r.uni_dc_unc) < 0) {
+ return WERR_GENERAL_FAILURE;
+ }
+ if (*tmp == '\\') tmp += 1;
+ if (*tmp == '\\') tmp += 1;
+
+ /* We have to talloc_strdup, otherwise a talloc_steal would
+ fail */
+ *dc_unc = talloc_strdup(mem_ctx, tmp);
+ if (*dc_unc == NULL) {
+ return WERR_NOMEM;
+ }
+ }
+
+ if (dc_address != NULL) {
+ char *tmp;
+ if (rpcstr_pull_unistr2_talloc(mem_ctx, &tmp,
+ &r.uni_dc_address) < 0) {
+ return WERR_GENERAL_FAILURE;
+ }
+ if (*tmp == '\\') tmp += 1;
+ if (*tmp == '\\') tmp += 1;
+
+ /* We have to talloc_strdup, otherwise a talloc_steal would
+ fail */
+ *dc_address = talloc_strdup(mem_ctx, tmp);
+ if (*dc_address == NULL) {
+ return WERR_NOMEM;
+ }
+ }
+
+ if (dc_address_type != NULL) {
+ *dc_address_type = r.dc_address_type;
+ }
+
+ if (domain_guid_out != NULL) {
+ *domain_guid_out = r.domain_guid;
+ }
+
+ if ((domain_name_out != NULL) &&
+ (rpcstr_pull_unistr2_talloc(mem_ctx, domain_name_out,
+ &r.uni_domain_name) < 1)) {
+ return WERR_GENERAL_FAILURE;
+ }
+
+ if ((forest_name != NULL) &&
+ (rpcstr_pull_unistr2_talloc(mem_ctx, forest_name,
+ &r.uni_forest_name) < 1)) {
+ return WERR_GENERAL_FAILURE;
+ }
+
+ if (dc_flags != NULL) {
+ *dc_flags = r.dc_flags;
+ }
+
+ if ((dc_site_name != NULL) &&
+ (rpcstr_pull_unistr2_talloc(mem_ctx, dc_site_name,
+ &r.uni_dc_site_name) < 1)) {
+ return WERR_GENERAL_FAILURE;
+ }
+
+ if ((client_site_name != NULL) &&
+ (rpcstr_pull_unistr2_talloc(mem_ctx, client_site_name,
+ &r.uni_client_site_name) < 1)) {
+ return WERR_GENERAL_FAILURE;
+ }
+
+ return WERR_OK;
+}
+
+
/* Sam synchronisation */
NTSTATUS rpccli_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,