From: Stefan Metzmacher Date: Tue, 29 Nov 2016 10:09:46 +0000 (+0100) Subject: getncchanges: remember the ncRoot_guid on the getncchanges state X-Git-Tag: talloc-2.1.9~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=488eed6977e6bb04be2b1a736115d8887516ebbe;p=thirdparty%2Fsamba.git getncchanges: remember the ncRoot_guid on the getncchanges state BUG: https://bugzilla.samba.org/show_bug.cgi?id=12398 Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c index 654e7ac8e52..2860b90614a 100644 --- a/source4/rpc_server/drsuapi/getncchanges.c +++ b/source4/rpc_server/drsuapi/getncchanges.c @@ -44,6 +44,7 @@ struct drsuapi_getncchanges_state { uint32_t num_records; uint32_t num_processed; struct ldb_dn *ncRoot_dn; + struct GUID ncRoot_guid; bool is_schema_nc; uint64_t min_usn; uint64_t max_usn; @@ -1932,6 +1933,19 @@ allowed: } b_state->getncchanges_state = getnc_state; getnc_state->ncRoot_dn = drs_ObjectIdentifier_to_dn(getnc_state, sam_ctx, ncRoot); + if (getnc_state->ncRoot_dn == NULL) { + return WERR_NOT_ENOUGH_MEMORY; + } + + ret = dsdb_find_guid_by_dn(b_state->sam_ctx_system, + getnc_state->ncRoot_dn, + &getnc_state->ncRoot_guid); + if (ret != LDB_SUCCESS) { + DEBUG(0,(__location__ ": Failed to find GUID of ncRoot_dn %s\n", + ldb_dn_get_linearized(getnc_state->ncRoot_dn))); + return WERR_DS_DRA_INTERNAL_ERROR; + } + ncRoot->guid = getnc_state->ncRoot_guid; /* find out if we are to replicate Schema NC */ ret = ldb_dn_compare_base(ldb_get_schema_basedn(b_state->sam_ctx), @@ -2009,6 +2023,8 @@ allowed: return WERR_DS_DRA_INVALID_PARAMETER; } + ncRoot->guid = getnc_state->ncRoot_guid; + /* we need the session key for encrypting password attributes */ status = dcesrv_inherited_session_key(dce_call->conn, &session_key); if (!NT_STATUS_IS_OK(status)) { @@ -2119,14 +2135,10 @@ allowed: } r->out.ctr->ctr6.naming_context = talloc(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier); - *r->out.ctr->ctr6.naming_context = *ncRoot; - - if (dsdb_find_guid_by_dn(sam_ctx, getnc_state->ncRoot_dn, - &r->out.ctr->ctr6.naming_context->guid) != LDB_SUCCESS) { - DEBUG(0,(__location__ ": Failed to find GUID of ncRoot_dn %s\n", - ldb_dn_get_linearized(getnc_state->ncRoot_dn))); - return WERR_DS_DRA_INTERNAL_ERROR; + if (r->out.ctr->ctr6.naming_context == NULL) { + return WERR_NOT_ENOUGH_MEMORY; } + *r->out.ctr->ctr6.naming_context = *ncRoot; /* find the SID if there is one */ dsdb_find_sid_by_dn(sam_ctx, getnc_state->ncRoot_dn, &r->out.ctr->ctr6.naming_context->sid);