From: Gary Lockyer Date: Wed, 30 May 2018 02:43:25 +0000 (+1200) Subject: rpc_server: common routine to open ldb in system session X-Git-Tag: tevent-0.9.37~445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d48b5d5320807ef394d1d31c3f9e92b4955a4aea;p=thirdparty%2Fsamba.git rpc_server: common routine to open ldb in system session Add a function to open an ldb connection under the system session and save the remote users session details in a ldb_opaque. This will allow the audit logging to log the original session for operations performed in the system session. Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- diff --git a/source4/rpc_server/common/server_info.c b/source4/rpc_server/common/server_info.c index 0aabcdaebe7..7229457b54f 100644 --- a/source4/rpc_server/common/server_info.c +++ b/source4/rpc_server/common/server_info.c @@ -186,3 +186,29 @@ bool dcesrv_common_validate_share_name(TALLOC_CTX *mem_ctx, const char *share_na return true; } + +/* + * Open an ldb connection under the system session and save the remote users + * session details in a ldb_opaque. This will allow the audit logging to + * log the original session for operations performed in the system session. + */ +struct ldb_context *dcesrv_samdb_connect_as_system( + TALLOC_CTX *mem_ctx, + struct dcesrv_call_state *dce_call) +{ + struct ldb_context *samdb = NULL; + samdb = samdb_connect( + mem_ctx, + dce_call->event_ctx, + dce_call->conn->dce_ctx->lp_ctx, + system_session(dce_call->conn->dce_ctx->lp_ctx), + dce_call->conn->remote_address, + 0); + if (samdb) { + ldb_set_opaque( + samdb, + "networkSessionInfo", + dce_call->conn->auth_state.session_info); + } + return samdb; +}