2 #include "system/kerberos.h"
3 #include "auth/kerberos/kerberos.h"
5 #include "kdc/hdb-samba4.h"
6 #include "libnet/libnet.h"
8 NTSTATUS
libnet_export_keytab(struct libnet_context
*ctx
, TALLOC_CTX
*mem_ctx
, struct libnet_export_keytab
*r
)
11 struct smb_krb5_context
*smb_krb5_context
;
12 const char *from_keytab
;
14 /* Register hdb-samba4 hooks for use as a keytab */
16 struct samba_kdc_base_context
*base_ctx
= talloc_zero(mem_ctx
, struct samba_kdc_base_context
);
18 return NT_STATUS_NO_MEMORY
;
21 base_ctx
->ev_ctx
= ctx
->event_ctx
;
22 base_ctx
->lp_ctx
= ctx
->lp_ctx
;
24 from_keytab
= talloc_asprintf(base_ctx
, "HDB:samba4&%p", base_ctx
);
26 return NT_STATUS_NO_MEMORY
;
29 ret
= smb_krb5_init_context(ctx
, ctx
->event_ctx
, ctx
->lp_ctx
, &smb_krb5_context
);
31 return NT_STATUS_NO_MEMORY
;
34 ret
= krb5_plugin_register(smb_krb5_context
->krb5_context
,
35 PLUGIN_TYPE_DATA
, "hdb",
38 return NT_STATUS_NO_MEMORY
;
41 ret
= krb5_kt_register(smb_krb5_context
->krb5_context
, &hdb_kt_ops
);
43 return NT_STATUS_NO_MEMORY
;
46 ret
= kt_copy(smb_krb5_context
->krb5_context
, from_keytab
, r
->in
.keytab_name
);
48 r
->out
.error_string
= smb_get_krb5_error_message(smb_krb5_context
->krb5_context
,
50 return NT_STATUS_UNSUCCESSFUL
;