s4-rpc_server/drsuapi: Fix timeouts on forwarded DsExecuteKCC IRPC call
[samba.git] / source4 / rpc_server / drsuapi / dcesrv_drsuapi.c
index 927e98ba518174dc7b71107b834d9e3ebdc3252f..d33131348a8ae73d7906889ec5e7dc32ad869c62 100644 (file)
@@ -807,6 +807,7 @@ static WERROR dcesrv_drsuapi_DsExecuteKCC(struct dcesrv_call_state *dce_call, TA
                                  struct drsuapi_DsExecuteKCC *r)
 {
        WERROR status;
+       uint32_t timeout;
        status = drs_security_level_check(dce_call, "DsExecuteKCC", SECURITY_DOMAIN_CONTROLLER, NULL);
 
        if (!W_ERROR_IS_OK(status)) {
@@ -815,9 +816,20 @@ static WERROR dcesrv_drsuapi_DsExecuteKCC(struct dcesrv_call_state *dce_call, TA
        if (r->in.req->ctr1.taskID != 0) {
                return WERR_INVALID_PARAM;
        }
+       if (r->in.req->ctr1.flags & DRSUAPI_DS_EXECUTE_KCC_ASYNCHRONOUS_OPERATION) {
+               timeout = IRPC_CALL_TIMEOUT;
+       } else {
+               /*
+                * use Infinite time for timeout in case
+                * the caller made a sync call
+                */
+               timeout = IRPC_CALL_TIMEOUT_INF;
+       }
+
        dcesrv_irpc_forward_rpc_call(dce_call, mem_ctx, r, NDR_DRSUAPI_DSEXECUTEKCC,
                                     &ndr_table_drsuapi, "kccsrv", "DsExecuteKCC",
-                                    IRPC_CALL_TIMEOUT);
+                                    timeout);
+       DEBUG(0, ("Forwarded the call to execute the KCC\n"));
        return WERR_OK;
 }