netlogon_creds_cli: Create cli_credentials from netlogon creds ctx
authorVolker Lendecke <vl@samba.org>
Thu, 7 Sep 2017 10:36:14 +0000 (12:36 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 25 Sep 2017 07:43:12 +0000 (09:43 +0200)
A netlogon_creds_cli_context holds all information required to do an
schannel bind. Used in the next commit.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/auth/netlogon_creds_cli.c
libcli/auth/netlogon_creds_cli.h

index c3b302addc4c7dc37f5ba3869fb2537cc50598b4..25f14316dc2a2987faba9266eb2dbb31c835f320 100644 (file)
@@ -38,6 +38,7 @@
 #include "source3/include/g_lock.h"
 #include "libds/common/roles.h"
 #include "lib/crypto/crypto.h"
+#include "auth/credentials/credentials.h"
 
 struct netlogon_creds_cli_locked_state;
 
@@ -447,6 +448,37 @@ NTSTATUS netlogon_creds_cli_context_global(struct loadparm_context *lp_ctx,
        return NT_STATUS_OK;
 }
 
+NTSTATUS netlogon_creds_bind_cli_credentials(
+       struct netlogon_creds_cli_context *context, TALLOC_CTX *mem_ctx,
+       struct cli_credentials **pcli_creds)
+{
+       struct cli_credentials *cli_creds;
+       struct netlogon_creds_CredentialState *ncreds;
+       NTSTATUS status;
+
+       cli_creds = cli_credentials_init(mem_ctx);
+       if (cli_creds == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       cli_credentials_set_secure_channel_type(cli_creds,
+                                               context->client.type);
+       cli_credentials_set_username(cli_creds, context->client.account,
+                                    CRED_SPECIFIED);
+       cli_credentials_set_domain(cli_creds, context->server.netbios_domain,
+                                  CRED_SPECIFIED);
+       cli_credentials_set_realm(cli_creds, context->server.dns_domain,
+                                 CRED_SPECIFIED);
+
+       status = netlogon_creds_cli_get(context, cli_creds, &ncreds);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(cli_creds);
+               return status;
+       }
+
+       *pcli_creds = cli_creds;
+       return NT_STATUS_OK;
+}
+
 char *netlogon_creds_cli_debug_string(
                const struct netlogon_creds_cli_context *context,
                TALLOC_CTX *mem_ctx)
index 1e7df6600cbacae410ff36aed9a648db00ef5d19..7664387ab9548ebd23e6fbfa30740f623052051e 100644 (file)
@@ -26,6 +26,7 @@
 #include "librpc/gen_ndr/schannel.h"
 
 struct netlogon_creds_cli_context;
+struct cli_credentials;
 struct messaging_context;
 struct dcerpc_binding_handle;
 struct db_context;
@@ -43,6 +44,9 @@ NTSTATUS netlogon_creds_cli_context_global(struct loadparm_context *lp_ctx,
                                const char *server_dns_domain,
                                TALLOC_CTX *mem_ctx,
                                struct netlogon_creds_cli_context **_context);
+NTSTATUS netlogon_creds_bind_cli_credentials(
+       struct netlogon_creds_cli_context *context, TALLOC_CTX *mem_ctx,
+       struct cli_credentials **pcli_creds);
 
 char *netlogon_creds_cli_debug_string(
                const struct netlogon_creds_cli_context *context,