-/****************************************************************************
- Open a named pipe to an SMB server and bind using the mech specified
-
- This routine steals the creds pointer that is passed in
- ****************************************************************************/
-
-NTSTATUS cli_rpc_pipe_open_generic_auth(struct cli_state *cli,
- const struct ndr_interface_table *table,
- enum dcerpc_transport_t transport,
- enum dcerpc_AuthType auth_type,
- enum dcerpc_AuthLevel auth_level,
- const char *server,
- const char *domain,
- const char *username,
- const char *password,
- struct rpc_pipe_client **presult)
-{
- struct rpc_pipe_client *result;
- struct pipe_auth_data *auth = NULL;
- const char *target_service = table->authservices->names[0];
-
- NTSTATUS status;
-
- status = cli_rpc_pipe_open(cli, transport, table, &result);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- status = rpccli_generic_bind_data(result,
- auth_type, auth_level,
- server, target_service,
- domain, username, password,
- CRED_AUTO_USE_KERBEROS,
- NULL,
- &auth);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("rpccli_generic_bind_data returned %s\n",
- nt_errstr(status)));
- goto err;
- }
-
- status = rpc_pipe_bind(result, auth);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("cli_rpc_pipe_open_generic_auth: cli_rpc_pipe_bind failed with error %s\n",
- nt_errstr(status) ));
- goto err;
- }
-
- DEBUG(10,("cli_rpc_pipe_open_generic_auth: opened pipe %s to "
- "machine %s and bound as user %s\\%s.\n", table->name,
- result->desthost, domain, username));
-
- *presult = result;
- return NT_STATUS_OK;
-
- err:
-
- TALLOC_FREE(result);
- return status;
-}
-