1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

dsgetdcname: use existing messaging_context if possible.

Guenther
(This used to be commit 7889516a384c155a9045aad4409c041fddd0d98d)
This commit is contained in:
Günther Deschner 2008-05-08 18:32:22 +02:00
parent c58ab8f3b2
commit 67c644aa59
9 changed files with 31 additions and 11 deletions

View File

@ -118,6 +118,7 @@ WERROR DsGetDcName_l(struct libnetapi_ctx *ctx,
NTSTATUS status;
status = dsgetdcname(ctx,
NULL,
r->in.domain_name,
r->in.domain_guid,
r->in.site_name,

View File

@ -51,7 +51,7 @@ WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx,
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
DS_WRITABLE_REQUIRED |
DS_RETURN_DNS_NAME;
status = dsgetdcname(mem_ctx, r->in.domain,
status = dsgetdcname(mem_ctx, NULL, r->in.domain,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
libnetapi_set_error_string(mem_ctx,
@ -180,7 +180,7 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx,
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
DS_WRITABLE_REQUIRED |
DS_RETURN_DNS_NAME;
status = dsgetdcname(mem_ctx, domain,
status = dsgetdcname(mem_ctx, NULL, domain,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
libnetapi_set_error_string(mem_ctx,
@ -360,7 +360,7 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
DS_RETURN_DNS_NAME;
status = dsgetdcname(ctx, r->in.domain,
status = dsgetdcname(ctx, NULL, r->in.domain,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
libnetapi_set_error_string(ctx, "%s",

View File

@ -1622,6 +1622,7 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
struct netr_DsRGetDCNameInfo *info;
const char *dc;
status = dsgetdcname(mem_ctx,
r->in.msg_ctx,
r->in.domain_name,
NULL,
NULL,
@ -1778,6 +1779,7 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
struct netr_DsRGetDCNameInfo *info;
const char *dc;
status = dsgetdcname(mem_ctx,
r->in.msg_ctx,
r->in.domain_name,
NULL,
NULL,

View File

@ -28,6 +28,7 @@ struct libnet_JoinCtx {
struct ads_struct *ads;/* [ref] */
uint8_t debug;
enum netr_SchannelType secure_channel_type;
struct messaging_context *msg_ctx;/* [noprint,ref] */
} in;
struct {
@ -59,6 +60,7 @@ struct libnet_UnjoinCtx {
struct dom_sid *domain_sid;/* [ref] */
struct ads_struct *ads;/* [ref] */
uint8_t debug;
struct messaging_context *msg_ctx;/* [noprint,ref] */
} in;
struct {

View File

@ -31,6 +31,7 @@ interface libnetjoin
[in] ads_struct *ads,
[in] boolean8 debug,
[in] netr_SchannelType secure_channel_type,
[in,noprint] messaging_context *msg_ctx,
[out] string account_name,
[out] string netbios_domain_name,
[out] string dns_domain_name,
@ -54,6 +55,7 @@ interface libnetjoin
[in] dom_sid *domain_sid,
[in] ads_struct *ads,
[in] boolean8 debug,
[in,noprint] messaging_context *msg_ctx,
[out] string netbios_domain_name,
[out] string dns_domain_name,
[out] boolean8 modified_config,

View File

@ -330,6 +330,7 @@ static NTSTATUS store_cldap_reply(TALLOC_CTX *mem_ctx,
****************************************************************/
static NTSTATUS dsgetdcname_cache_refresh(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
@ -339,6 +340,7 @@ static NTSTATUS dsgetdcname_cache_refresh(TALLOC_CTX *mem_ctx,
struct netr_DsRGetDCNameInfo *dc_info;
return dsgetdcname(mem_ctx,
msg_ctx,
domain_name,
domain_guid,
site_name,
@ -494,6 +496,7 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
****************************************************************/
static NTSTATUS dsgetdcname_cached(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
@ -516,7 +519,8 @@ static NTSTATUS dsgetdcname_cached(TALLOC_CTX *mem_ctx,
}
if (expired) {
status = dsgetdcname_cache_refresh(mem_ctx, domain_name,
status = dsgetdcname_cache_refresh(mem_ctx, msg_ctx,
domain_name,
domain_guid, flags,
site_name, *info);
if (!NT_STATUS_IS_OK(status)) {
@ -1119,6 +1123,7 @@ static struct messaging_context *msg_context(TALLOC_CTX *mem_ctx)
****************************************************************/
static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const char *domain_name,
uint32_t flags,
struct ip_service_name *dclist,
@ -1132,12 +1137,15 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
int i;
const char *dc_name = NULL;
fstring tmp_dc_name;
struct messaging_context *msg_ctx = msg_context(mem_ctx);
union nbt_cldap_netlogon *r = NULL;
uint32_t nt_version = NETLOGON_VERSION_1 |
NETLOGON_VERSION_5 |
NETLOGON_VERSION_5EX_WITH_IP;
if (!msg_ctx) {
msg_ctx = msg_context(mem_ctx);
}
if (flags & DS_PDC_REQUIRED) {
name_type = NBT_NAME_PDC;
}
@ -1221,6 +1229,7 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
****************************************************************/
static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const char *domain_name,
struct GUID *domain_guid,
uint32_t flags,
@ -1239,7 +1248,7 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
&dclist, &num_dcs);
NT_STATUS_NOT_OK_RETURN(status);
return process_dc_netbios(mem_ctx, domain_name, flags,
return process_dc_netbios(mem_ctx, msg_ctx, domain_name, flags,
dclist, num_dcs, info);
}
@ -1269,7 +1278,7 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
&num_dcs);
NT_STATUS_NOT_OK_RETURN(status);
return process_dc_netbios(mem_ctx, domain_name, flags, dclist,
return process_dc_netbios(mem_ctx, msg_ctx, domain_name, flags, dclist,
num_dcs, info);
}
@ -1280,6 +1289,7 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
********************************************************************/
NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const char *domain_name,
struct GUID *domain_guid,
const char *site_name,
@ -1306,7 +1316,7 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
goto rediscover;
}
status = dsgetdcname_cached(mem_ctx, domain_name, domain_guid,
status = dsgetdcname_cached(mem_ctx, msg_ctx, domain_name, domain_guid,
flags, site_name, &myinfo);
if (NT_STATUS_IS_OK(status)) {
*info = myinfo;
@ -1318,7 +1328,7 @@ NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
}
rediscover:
status = dsgetdcname_rediscover(mem_ctx, domain_name,
status = dsgetdcname_rediscover(mem_ctx, msg_ctx, domain_name,
domain_guid, flags, site_name,
&myinfo);

View File

@ -341,6 +341,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p,
j->in.admin_password = cleartext_pwd;
j->in.debug = true;
j->in.modify_config = lp_config_backend_is_registry();
j->in.msg_ctx = smbd_messaging_context();
become_root();
werr = libnet_Join(p->mem_ctx, j);
@ -407,6 +408,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p,
u->in.admin_password = cleartext_pwd;
u->in.debug = true;
u->in.modify_config = lp_config_backend_is_registry();
u->in.msg_ctx = smbd_messaging_context();
become_root();
werr = libnet_Unjoin(p->mem_ctx, u);

View File

@ -402,7 +402,7 @@ static int net_lookup_dsgetdcname(int argc, const char **argv)
site_name = sitename_fetch(domain_name);
}
status = dsgetdcname(mem_ctx, domain_name, NULL, site_name,
status = dsgetdcname(mem_ctx, NULL, domain_name, NULL, site_name,
flags, &info);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed with: %s\n", nt_errstr(status));

View File

@ -67,7 +67,8 @@ static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain,
DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state->pid,
state->request.domain_name));
result = dsgetdcname(state->mem_ctx, state->request.domain_name,
result = dsgetdcname(state->mem_ctx, winbind_messaging_context(),
state->request.domain_name,
NULL, NULL, state->request.flags, &info);
if (!NT_STATUS_IS_OK(result)) {