Question on updating dcerpc_Foo calls to new API

Brad Hards bradh at
Tue Aug 17 01:11:44 MDT 2010

G'day Metze,

I'm trying to update OpenChange to the new API, but I'm not feeling
confident about the required changes. I'm hoping for some guidance...

Lets take an example from libmapi/IMSProvider.c, slightly simplified.

_PUBLIC_ char *RfrGetNewDSA(struct mapi_session *session,
                            const char *server, 
                            const char *userDN)
        NTSTATUS                status;
        TALLOC_CTX              *mem_ctx;
        struct mapi_profile     *profile;
        struct RfrGetNewDSA     r;
        struct dcerpc_pipe      *pipe;
        char                    *binding;
        char                    *ppszServer = NULL;

        profile = session->profile;

        binding = build_binding_string(mem_ctx, server, profile);
        status = provider_rpc_connection(mem_ctx, &pipe, binding, profile->credentials, &ndr_table_exchange_ds_rfr, global_mapi_ctx->lp_ctx);
        talloc_free(binding); = 0x0; = userDN ? userDN : ""; = NULL; = (const char **) &ppszServer;

        status = dcerpc_RfrGetNewDSA(pipe, mem_ctx, &r);
        if ((!NT_STATUS_IS_OK(status) || !ppszServer) && server) {
                ppszServer = talloc_strdup((TALLOC_CTX *)session, server);
        } else {
                ppszServer = talloc_steal((TALLOC_CTX *)session, ppszServer);

        return ppszServer;

provider_rpc_connection is basically a wrapper around  dcerpc_pipe_connect(),
which takes the same kind of things (binding string, table, context) as the
new dcerpc_RfrGetNewDSA() API. That feels wrong.

So while a change to something like:
- = 0x0;
- = userDN ? userDN : "";
- = NULL;
- = (const char **) &ppszServer;
-       status = dcerpc_RfrGetNewDSA(pipe, mem_ctx, &r);
+       status = dcerpc_RfrGetNewDSA( pipe->binding_handle , mem_ctx, 0x0, userDN ? userDN : "",
+                                     NULL, (const char **) &ppszServer, &result );
does (appear to) work, it feels incorrect.

Where am I meant to get the binding_handle argument if I was Doing It Right?


More information about the samba-technical mailing list