mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
s3-dsgetdcname: add dsgetonedcname()
The idea is to run the same DC validation steps as for dsgetdcname() just omit the query list of DCs via DNS/netbios step but instead validate a given DC right away. Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
This commit is contained in:
@ -1212,3 +1212,56 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
NTSTATUS dsgetonedcname(TALLOC_CTX *mem_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
const char *domain_name,
|
||||
const char *dcname,
|
||||
uint32_t flags,
|
||||
struct netr_DsRGetDCNameInfo **info)
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct sockaddr_storage *addrs;
|
||||
unsigned int num_addrs, i;
|
||||
const char *hostname = strip_hostname(dcname);
|
||||
|
||||
status = resolve_name_list(mem_ctx, hostname, 0x20,
|
||||
&addrs, &num_addrs);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_addrs; i++) {
|
||||
|
||||
bool ok;
|
||||
struct ip_service_name dclist;
|
||||
|
||||
dclist.hostname = hostname;
|
||||
ok = sockaddr_storage_to_samba_sockaddr(&dclist.sa, &addrs[i]);
|
||||
if (!ok) {
|
||||
TALLOC_FREE(addrs);
|
||||
return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
|
||||
}
|
||||
|
||||
status = process_dc_dns(mem_ctx, domain_name, flags,
|
||||
&dclist, 1, info);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(addrs);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
if (lp_disable_netbios()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
status = process_dc_netbios(mem_ctx, msg_ctx, domain_name, flags,
|
||||
&dclist, 1, info);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(addrs);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
TALLOC_FREE(addrs);
|
||||
return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
|
||||
}
|
||||
|
@ -34,4 +34,10 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
|
||||
uint32_t flags,
|
||||
struct netr_DsRGetDCNameInfo **info);
|
||||
|
||||
NTSTATUS dsgetonedcname(TALLOC_CTX *mem_ctx,
|
||||
struct messaging_context *msg_ctx,
|
||||
const char *domain_name,
|
||||
const char *dcname,
|
||||
uint32_t flags,
|
||||
struct netr_DsRGetDCNameInfo **info);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user