Finish removal of iconv_convenience in public API's.
[bbaumbach/samba-autobuild/.git] / source4 / dsdb / repl / drepl_partitions.c
index 9a24fe541a17d63128c8278d3637838ff3ab57c8..cb45b41248fbd0dd1cb1ce86db1aad4213ad0659 100644 (file)
@@ -40,7 +40,7 @@ WERROR dreplsrv_load_partitions(struct dreplsrv_service *s)
        struct ldb_result *r;
        struct ldb_message_element *el;
        static const char *attrs[] = { "hasMasterNCs", NULL };
-       uint32_t i;
+       unsigned int i;
        int ret;
 
        basedn = samdb_ntds_settings_dn(s->samdb);
@@ -153,7 +153,7 @@ static WERROR dreplsrv_partition_add_source_dsa(struct dreplsrv_service *s,
        W_ERROR_HAVE_NO_MEMORY(source);
 
        ndr_err = ndr_pull_struct_blob(val, source, 
-                                      lp_iconv_convenience(s->task->lp_ctx), &source->_repsFromBlob,
+                                      &source->_repsFromBlob,
                                       (ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
@@ -195,7 +195,7 @@ static WERROR udv_convert(TALLOC_CTX *mem_ctx,
                          const struct replUpToDateVectorCtr2 *udv,
                          struct drsuapi_DsReplicaCursorCtrEx *udv_ex)
 {
-       int i;
+       uint32_t i;
 
        udv_ex->version = 2;
        udv_ex->reserved1 = 0;
@@ -212,57 +212,20 @@ static WERROR udv_convert(TALLOC_CTX *mem_ctx,
        return WERR_OK;
 }
 
-/*
-  add our local UDV element for the partition
- */
-static WERROR add_local_udv(struct dreplsrv_service *s,
-                           struct dreplsrv_partition *p,
-                           const struct GUID *our_invocation_id,
-                           struct drsuapi_DsReplicaCursorCtrEx *udv)
-{
-       int ret;
-       uint64_t highest_usn;
-       int i;
-
-       ret = dsdb_load_partition_usn(s->samdb, p->dn, &highest_usn);
-       if (ret != LDB_SUCCESS) {
-               /* nothing to add */
-               return WERR_OK;
-       }
-
-       for (i=0; i<udv->count; i++) {
-               if (GUID_equal(our_invocation_id, &udv->cursors[i].source_dsa_invocation_id)) {
-                       udv->cursors[i].highest_usn = highest_usn;
-                       return WERR_OK;
-               }
-       }
-
-       udv->cursors = talloc_realloc(p, udv->cursors, struct drsuapi_DsReplicaCursor, udv->count+1);
-       W_ERROR_HAVE_NO_MEMORY(udv->cursors);
-
-       udv->cursors[udv->count].source_dsa_invocation_id = *our_invocation_id;
-       udv->cursors[udv->count].highest_usn = highest_usn;
-       udv->count++;
-
-       return WERR_OK;
-}
 
 static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
                                         struct dreplsrv_partition *p)
 {
        WERROR status;
-       const struct ldb_val *ouv_value;
-       struct replUpToDateVectorBlob ouv;
        struct dom_sid *nc_sid;
        struct ldb_message_element *orf_el = NULL;
        struct ldb_result *r;
-       uint32_t i;
+       unsigned int i;
        int ret;
        TALLOC_CTX *mem_ctx = talloc_new(p);
        static const char *attrs[] = {
                "objectSid",
                "objectGUID",
-               "replUpToDateVector",
                "repsFrom",
                NULL
        };
@@ -275,9 +238,6 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
        if (ret != LDB_SUCCESS) {
                talloc_free(mem_ctx);
                return WERR_FOOBAR;
-       } else if (r->count != 1) {
-               talloc_free(mem_ctx);
-               return WERR_FOOBAR;
        }
        
        talloc_free(discard_const(p->nc.dn));
@@ -296,34 +256,12 @@ static WERROR dreplsrv_refresh_partition(struct dreplsrv_service *s,
        ZERO_STRUCT(p->uptodatevector);
        ZERO_STRUCT(p->uptodatevector_ex);
 
-       ouv_value = ldb_msg_find_ldb_val(r->msgs[0], "replUpToDateVector");
-       if (ouv_value) {
-               enum ndr_err_code ndr_err;
-               ndr_err = ndr_pull_struct_blob(ouv_value, mem_ctx, 
-                                              lp_iconv_convenience(s->task->lp_ctx), &ouv,
-                                              (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob);
-               if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-                       NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
-                       talloc_free(mem_ctx);
-                       return ntstatus_to_werror(nt_status);
-               }
-               /* NDR_PRINT_DEBUG(replUpToDateVectorBlob, &ouv); */
-               if (ouv.version != 2) {
-                       talloc_free(mem_ctx);
-                       return WERR_DS_DRA_INTERNAL_ERROR;
-               }
-
-               p->uptodatevector.count         = ouv.ctr.ctr2.count;
-               p->uptodatevector.reserved      = ouv.ctr.ctr2.reserved;
-               p->uptodatevector.cursors       = talloc_steal(p, ouv.ctr.ctr2.cursors);
-
+       ret = dsdb_load_udv_v2(s->samdb, p->dn, p, &p->uptodatevector.cursors, &p->uptodatevector.count);
+       if (ret == LDB_SUCCESS) {
                status = udv_convert(p, &p->uptodatevector, &p->uptodatevector_ex);
                W_ERROR_NOT_OK_RETURN(status);
        }
 
-       status = add_local_udv(s, p, samdb_ntds_invocation_id(s->samdb), &p->uptodatevector_ex);
-       W_ERROR_NOT_OK_RETURN(status);
-
        orf_el = ldb_msg_find_element(r->msgs[0], "repsFrom");
        if (orf_el) {
                for (i=0; i < orf_el->num_values; i++) {