Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-wsgi
[kai/samba.git] / source / libnet / libnet_samdump_keytab.c
index de575ec66893913020910a805d3d6ff8f24b9298..0c4d3e5c595342720675227f4988f63a43a297f8 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 
 #include "includes.h"
 #include "libnet/libnet.h"
 #include "system/kerberos.h"
+#include "auth/credentials/credentials.h"
+#include "auth/credentials/credentials_krb5.h"
+#include "param/param.h"
+#include "lib/events/events.h"
 
 static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
+                                          struct event_context *event_ctx,
+                                          struct loadparm_context *lp_ctx,
                                            const char *keytab_name,
                                            struct netr_DELTA_ENUM *delta) 
 {
@@ -43,19 +48,19 @@ static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
        if (!credentials) {
                return NT_STATUS_NO_MEMORY;
        }
-       cli_credentials_set_conf(credentials);
+       cli_credentials_set_conf(credentials, lp_ctx);
        cli_credentials_set_username(credentials, username, CRED_SPECIFIED);
 
        /* We really should consult ldap in the main SamSync code, and
         * pass a value in here */
        cli_credentials_set_kvno(credentials, 0);
        cli_credentials_set_nt_hash(credentials, &user->ntpassword, CRED_SPECIFIED);
-       ret = cli_credentials_set_keytab_name(credentials, keytab_name, CRED_SPECIFIED);
+       ret = cli_credentials_set_keytab_name(credentials, event_ctx, lp_ctx, keytab_name, CRED_SPECIFIED);
        if (ret) {
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       ret = cli_credentials_update_keytab(credentials);
+       ret = cli_credentials_update_keytab(credentials, event_ctx, lp_ctx);
        if (ret) {
                return NT_STATUS_UNSUCCESSFUL;
        }
@@ -79,6 +84,8 @@ static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx,
                /* not interested in builtin users */
                if (database == SAM_DATABASE_DOMAIN) {
                        nt_status = samdump_keytab_handle_user(mem_ctx, 
+                                                              event_context_find(mem_ctx),
+                                                              global_loadparm,
                                                               keytab_name,
                                                               delta);
                        break;
@@ -98,6 +105,7 @@ NTSTATUS libnet_SamDump_keytab(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
 
        r2.out.error_string            = NULL;
        r2.in.binding_string           = r->in.binding_string;
+       r2.in.rid_crypt                = true;
        r2.in.init_fn                  = NULL;
        r2.in.delta_fn                 = libnet_samdump_keytab_fn;
        r2.in.fn_ctx                   = discard_const(r->in.keytab_name);