summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-12-19 02:25:15 +0100
committerGünther Deschner <gd@samba.org>2007-12-21 15:29:10 +0100
commitd1548d035f3c296d5044b9aa47fc350cb62e4e2d (patch)
tree519ff4a4e62cc0b30f034f8d6e96e7a2ce335d33 /source3/lib
parent8f65326e9993a5caefde89f9a48cd677a9f0cefd (diff)
downloadsamba-d1548d035f3c296d5044b9aa47fc350cb62e4e2d.tar.gz
samba-d1548d035f3c296d5044b9aa47fc350cb62e4e2d.tar.bz2
samba-d1548d035f3c296d5044b9aa47fc350cb62e4e2d.zip
Use DsGetDcName in local libnetapi join to find a dc.
Guenther (This used to be commit fbc60c1648ff8b1fa0ae33c09237e41232f9769c)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/netapi/joindomain.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c
index a0d3319998..c6bf3d687a 100644
--- a/source3/lib/netapi/joindomain.c
+++ b/source3/lib/netapi/joindomain.c
@@ -36,16 +36,31 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
werr = libnet_init_JoinCtx(mem_ctx, &r);
W_ERROR_NOT_OK_RETURN(werr);
- if (!server_name || !domain_name) {
+ if (!domain_name) {
return WERR_INVALID_PARAM;
}
- r->in.server_name = talloc_strdup(mem_ctx, server_name);
- W_ERROR_HAVE_NO_MEMORY(r->in.server_name);
-
r->in.domain_name = talloc_strdup(mem_ctx, domain_name);
W_ERROR_HAVE_NO_MEMORY(r->in.domain_name);
+ if (server_name) {
+ r->in.server_name = talloc_strdup(mem_ctx, server_name);
+ W_ERROR_HAVE_NO_MEMORY(r->in.server_name);
+ } else if (join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
+ NTSTATUS status;
+ struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
+ uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
+ DS_WRITABLE_REQUIRED |
+ DS_RETURN_DNS_NAME;
+ status = DsGetDcName(mem_ctx, NULL, domain_name,
+ NULL, NULL, flags, &info);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
+ r->in.server_name = talloc_strdup(mem_ctx, info->domain_controller_name);
+ W_ERROR_HAVE_NO_MEMORY(r->in.server_name);
+ }
+
if (account_ou) {
r->in.account_ou = talloc_strdup(mem_ctx, account_ou);
W_ERROR_HAVE_NO_MEMORY(r->in.account_ou);
@@ -158,17 +173,8 @@ static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx,
if (!server_name || is_myname_or_ipaddr(server_name)) {
- const char *dc = NULL;
-
- /* FIXME: DsGetDcName */
- if (server_name == NULL) {
- dc = domain_name;
- } else {
- dc = domain_name;
- }
-
werr = NetJoinDomainLocal(ctx,
- dc,
+ server_name,
domain_name,
account_ou,
Account,