summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/rpc_server/drsuapi/dcesrv_drsuapi.h3
-rw-r--r--source4/rpc_server/drsuapi/drsutil.c31
-rw-r--r--source4/rpc_server/drsuapi/getncchanges.c3
3 files changed, 29 insertions, 8 deletions
diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
index 685203360b..a6b11c5dac 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
@@ -54,7 +54,8 @@ int drsuapi_search_with_extended_dn(struct ldb_context *ldb,
struct ldb_dn *basedn,
enum ldb_scope scope,
const char * const *attrs,
- const char *format, ...) PRINTF_ATTRIBUTE(7,8);
+ const char *sort_attrib,
+ const char *format, ...) PRINTF_ATTRIBUTE(8,9);
WERROR drs_security_level_check(struct dcesrv_call_state *dce_call,
const char* call);
diff --git a/source4/rpc_server/drsuapi/drsutil.c b/source4/rpc_server/drsuapi/drsutil.c
index 03116f29d9..ef48a9f079 100644
--- a/source4/rpc_server/drsuapi/drsutil.c
+++ b/source4/rpc_server/drsuapi/drsutil.c
@@ -44,12 +44,13 @@ char *drs_ObjectIdentifier_to_string(TALLOC_CTX *mem_ctx,
}
int drsuapi_search_with_extended_dn(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_result **_res,
- struct ldb_dn *basedn,
- enum ldb_scope scope,
- const char * const *attrs,
- const char *format, ...)
+ TALLOC_CTX *mem_ctx,
+ struct ldb_result **_res,
+ struct ldb_dn *basedn,
+ enum ldb_scope scope,
+ const char * const *attrs,
+ const char *sort_attrib,
+ const char *format, ...)
{
va_list ap;
int ret;
@@ -93,6 +94,24 @@ int drsuapi_search_with_extended_dn(struct ldb_context *ldb,
return ret;
}
+ if (sort_attrib) {
+ struct ldb_server_sort_control *sort_control;
+ sort_control = talloc(req, struct ldb_server_sort_control);
+ if (sort_control == NULL) {
+ talloc_free(tmp_ctx);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ sort_control->attributeName = sort_attrib;
+ sort_control->orderingRule = NULL;
+ sort_control->reverse = 1;
+
+ ret = ldb_request_add_control(req, LDB_CONTROL_SERVER_SORT_OID, true, sort_control);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+
+
ret = ldb_request(ldb, req);
if (ret == LDB_SUCCESS) {
ret = ldb_wait(req->handle, LDB_WAIT_ALL);
diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c
index 8538ea8ff1..56a37e9928 100644
--- a/source4/rpc_server/drsuapi/getncchanges.c
+++ b/source4/rpc_server/drsuapi/getncchanges.c
@@ -268,7 +268,7 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_
struct drsuapi_DsReplicaObjectListItemEx **currentObject;
NTSTATUS status;
DATA_BLOB session_key;
- const char *attrs[] = { "*", "parentGUID", NULL };
+ const char *attrs[] = { "*", "parentGUID", "distinguishedName", NULL };
WERROR werr;
*r->out.level_out = 6;
@@ -322,6 +322,7 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_
ncRoot_dn = ldb_dn_new(mem_ctx, sam_ctx, ncRoot->dn);
ret = drsuapi_search_with_extended_dn(sam_ctx, mem_ctx, &site_res,
ncRoot_dn, LDB_SCOPE_SUBTREE, attrs,
+ "distinguishedName",
"(uSNChanged>=%llu)",
(unsigned long long)(r->in.req->req8.highwatermark.highest_usn+1));
if (ret != LDB_SUCCESS) {