s3: Fix ntlm_auth and winbindd to use new common libcli/auth APIs
[kai/samba.git] / source3 / winbindd / winbindd_cm.c
index e06e30e0a89fdbe1a40cd9011c0b6b321b8fd0a6..f22f213eec6a927c41f6084a99c1eb73199e98a8 100644 (file)
@@ -60,6 +60,7 @@
 
 #include "includes.h"
 #include "winbindd.h"
+#include "../libcli/auth/libcli_auth.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
@@ -1772,8 +1773,8 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
        NTSTATUS                result;
        WERROR werr;
        TALLOC_CTX              *mem_ctx = NULL;
-       struct rpc_pipe_client  *cli;
-       POLICY_HND pol;
+       struct rpc_pipe_client  *cli = NULL;
+       struct policy_handle pol;
        union dssetup_DsRoleInfo info;
        union lsa_PolicyInformation *lsa_info = NULL;
 
@@ -1963,8 +1964,8 @@ static void set_dc_type_and_flags( struct winbindd_domain *domain )
 /**********************************************************************
 ***********************************************************************/
 
-static bool cm_get_schannel_dcinfo(struct winbindd_domain *domain,
-                                  struct dcinfo **ppdc)
+static bool cm_get_schannel_creds(struct winbindd_domain *domain,
+                                  struct netlogon_creds_CredentialState **ppdc)
 {
        NTSTATUS result;
        struct rpc_pipe_client *netlogon_pipe;
@@ -1978,7 +1979,7 @@ static bool cm_get_schannel_dcinfo(struct winbindd_domain *domain,
                return False;
        }
 
-       /* Return a pointer to the struct dcinfo from the
+       /* Return a pointer to the struct netlogon_creds_CredentialState from the
           netlogon pipe. */
 
        if (!domain->conn.netlogon_pipe->dc) {
@@ -1990,11 +1991,11 @@ static bool cm_get_schannel_dcinfo(struct winbindd_domain *domain,
 }
 
 NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
-                       struct rpc_pipe_client **cli, POLICY_HND *sam_handle)
+                       struct rpc_pipe_client **cli, struct policy_handle *sam_handle)
 {
        struct winbindd_cm_conn *conn;
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-       struct dcinfo *p_dcinfo;
+       struct netlogon_creds_CredentialState *p_creds;
        char *machine_password = NULL;
        char *machine_account = NULL;
        char *domain_name = NULL;
@@ -2081,7 +2082,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
 
        /* Fall back to schannel if it's a W2K pre-SP1 box. */
 
-       if (!cm_get_schannel_dcinfo(domain, &p_dcinfo)) {
+       if (!cm_get_schannel_creds(domain, &p_creds)) {
                /* If this call fails - conn->cli can now be NULL ! */
                DEBUG(10, ("cm_connect_sam: Could not get schannel auth info "
                           "for domain %s, trying anon\n", domain->name));
@@ -2089,7 +2090,7 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
        }
        result = cli_rpc_pipe_open_schannel_with_key
                (conn->cli, &ndr_table_samr.syntax_id, PIPE_AUTH_LEVEL_PRIVACY,
-                domain->name, p_dcinfo, &conn->samr_pipe);
+                domain->name, p_creds, &conn->samr_pipe);
 
        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(10,("cm_connect_sam: failed to connect to SAMR pipe for "
@@ -2156,11 +2157,11 @@ NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
 }
 
 NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
-                       struct rpc_pipe_client **cli, POLICY_HND *lsa_policy)
+                       struct rpc_pipe_client **cli, struct policy_handle *lsa_policy)
 {
        struct winbindd_cm_conn *conn;
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-       struct dcinfo *p_dcinfo;
+       struct netlogon_creds_CredentialState *p_creds;
 
        result = init_dc_connection(domain);
        if (!NT_STATUS_IS_OK(result))
@@ -2217,7 +2218,7 @@ NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
 
        /* Fall back to schannel if it's a W2K pre-SP1 box. */
 
-       if (!cm_get_schannel_dcinfo(domain, &p_dcinfo)) {
+       if (!cm_get_schannel_creds(domain, &p_creds)) {
                /* If this call fails - conn->cli can now be NULL ! */
                DEBUG(10, ("cm_connect_lsa: Could not get schannel auth info "
                           "for domain %s, trying anon\n", domain->name));
@@ -2226,7 +2227,7 @@ NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
        result = cli_rpc_pipe_open_schannel_with_key
                (conn->cli, &ndr_table_lsarpc.syntax_id,
                 PIPE_AUTH_LEVEL_PRIVACY,
-                domain->name, p_dcinfo, &conn->lsa_pipe);
+                domain->name, p_creds, &conn->lsa_pipe);
 
        if (!NT_STATUS_IS_OK(result)) {
                DEBUG(10,("cm_connect_lsa: failed to connect to LSA pipe for "