return flags;
}
-static int hdb_samba4_destructor(struct hdb_samba4_private *p)
+static int samba_kdc_entry_destructor(struct samba_kdc_entry *p)
{
hdb_entry_ex *entry_ex = p->entry_ex;
free_hdb_entry(&entry_ex->entry);
krb5_boolean is_computer = FALSE;
char *realm = strupper_talloc(mem_ctx, lp_realm(lp_ctx));
- struct hdb_samba4_private *p;
+ struct samba_kdc_entry *p;
NTTIME acct_expiry;
NTSTATUS status;
goto out;
}
- p = talloc(mem_ctx, struct hdb_samba4_private);
+ p = talloc(mem_ctx, struct samba_kdc_entry);
if (!p) {
ret = ENOMEM;
goto out;
}
+ p->kdc_db_ctx = kdc_db_ctx;
p->entry_ex = entry_ex;
- p->iconv_convenience = lp_iconv_convenience(lp_ctx);
- p->lp_ctx = lp_ctx;
p->realm_dn = talloc_reference(p, realm_dn);
if (!p->realm_dn) {
ret = ENOMEM;
goto out;
}
- talloc_set_destructor(p, hdb_samba4_destructor);
+ talloc_set_destructor(p, samba_kdc_entry_destructor);
entry_ex->ctx = p;
entry_ex->free_entry = hdb_samba4_free_entry;
entry_ex->entry.generation = NULL;
/* Get keys from the db */
- ret = hdb_samba4_message2entry_keys(context, p->iconv_convenience, p, msg, userAccountControl, entry_ex);
+ ret = hdb_samba4_message2entry_keys(context, p->kdc_db_ctx->ic_ctx, p,
+ msg, userAccountControl, entry_ex);
if (ret) {
/* Could be bougus data in the entry, or out of memory */
goto out;
p->msg = talloc_steal(p, msg);
- p->samdb = kdc_db_ctx->samdb;
out:
if (ret != 0) {
struct samr_Password password_hash;
const struct ldb_val *password_val;
struct trustAuthInOutBlob password_blob;
- struct hdb_samba4_private *p;
+ struct samba_kdc_entry *p;
enum ndr_err_code ndr_err;
int i, ret, trust_direction_flags;
- p = talloc(mem_ctx, struct hdb_samba4_private);
+ p = talloc(mem_ctx, struct samba_kdc_entry);
if (!p) {
ret = ENOMEM;
goto out;
}
+ p->kdc_db_ctx = kdc_db_ctx;
p->entry_ex = entry_ex;
- p->iconv_convenience = lp_iconv_convenience(lp_ctx);
- p->lp_ctx = lp_ctx;
p->realm_dn = realm_dn;
- talloc_set_destructor(p, hdb_samba4_destructor);
+ talloc_set_destructor(p, samba_kdc_entry_destructor);
entry_ex->ctx = p;
entry_ex->free_entry = hdb_samba4_free_entry;
goto out;
}
- ndr_err = ndr_pull_struct_blob(password_val, mem_ctx, p->iconv_convenience, &password_blob,
+ ndr_err = ndr_pull_struct_blob(password_val, mem_ctx, p->kdc_db_ctx->ic_ctx, &password_blob,
(ndr_pull_flags_fn_t)ndr_pull_trustAuthInOutBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
ret = EINVAL;
p->msg = talloc_steal(p, msg);
- p->samdb = kdc_db_ctx->samdb;
out:
if (ret != 0) {
struct ldb_message *msg;
struct dom_sid *orig_sid;
struct dom_sid *target_sid;
- struct hdb_samba4_private *p = talloc_get_type(entry->ctx, struct hdb_samba4_private);
+ struct samba_kdc_entry *p = talloc_get_type(entry->ctx, struct samba_kdc_entry);
const char *delegation_check_attrs[] = {
"objectSid", NULL
};
struct ldb_message *msg;
struct dom_sid *orig_sid;
struct dom_sid *target_sid;
- struct hdb_samba4_private *p = talloc_get_type(entry->ctx, struct hdb_samba4_private);
+ struct samba_kdc_entry *p = talloc_get_type(entry->ctx, struct samba_kdc_entry);
const char *ms_upn_check_attrs[] = {
"objectSid", NULL
};
}
kdc_db_ctx->ev_ctx = base_ctx->ev_ctx;
kdc_db_ctx->lp_ctx = base_ctx->lp_ctx;
+ kdc_db_ctx->ic_ctx = lp_iconv_convenience(base_ctx->lp_ctx);
/* Setup the link to LDB */
kdc_db_ctx->samdb = samdb_connect(kdc_db_ctx, base_ctx->ev_ctx,
Copyright (C) Andrew Tridgell 2005
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+ Copyright (C) Simo Sorce <idra@samba.org> 2010
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
struct samba_kdc_db_context {
struct tevent_context *ev_ctx;
struct loadparm_context *lp_ctx;
+ struct smb_iconv_convenience *ic_ctx;
struct ldb_context *samdb;
};
extern struct hdb_method hdb_samba4;
-struct hdb_samba4_private {
- struct ldb_context *samdb;
- struct smb_iconv_convenience *iconv_convenience;
- struct loadparm_context *lp_ctx;
+struct samba_kdc_entry {
+ struct samba_kdc_db_context *kdc_db_ctx;
struct ldb_message *msg;
struct ldb_dn *realm_dn;
hdb_entry_ex *entry_ex;
bool samba_princ_needs_pac(struct hdb_entry_ex *princ)
{
- struct hdb_samba4_private *p = talloc_get_type(princ->ctx, struct hdb_samba4_private);
+ struct samba_kdc_entry *p = talloc_get_type(princ->ctx, struct samba_kdc_entry);
unsigned int userAccountControl;
struct hdb_entry_ex *client,
DATA_BLOB **_pac_blob)
{
- struct hdb_samba4_private *p = talloc_get_type(client->ctx, struct hdb_samba4_private);
+ struct samba_kdc_entry *p = talloc_get_type(client->ctx, struct samba_kdc_entry);
struct auth_serversupplied_info *server_info;
DATA_BLOB *pac_blob;
NTSTATUS nt_status;
return NT_STATUS_NO_MEMORY;
}
- nt_status = authsam_make_server_info(mem_ctx, p->samdb,
- lp_netbios_name(p->lp_ctx),
- lp_sam_name(p->lp_ctx),
+ nt_status = authsam_make_server_info(mem_ctx, p->kdc_db_ctx->samdb,
+ lp_netbios_name(p->kdc_db_ctx->lp_ctx),
+ lp_sam_name(p->kdc_db_ctx->lp_ctx),
p->realm_dn,
p->msg,
data_blob(NULL, 0),
}
nt_status = samba_get_logon_info_pac_blob(mem_ctx,
- p->iconv_convenience,
+ p->kdc_db_ctx->ic_ctx,
server_info, pac_blob);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Building PAC failed: %s\n",
struct hdb_entry_ex *client,
struct hdb_entry_ex *server, krb5_pac *pac)
{
- struct hdb_samba4_private *p = talloc_get_type(server->ctx, struct hdb_samba4_private);
+ struct samba_kdc_entry *p = talloc_get_type(server->ctx, struct samba_kdc_entry);
TALLOC_CTX *mem_ctx = talloc_named(p, 0, "samba_kdc_reget_pac context");
DATA_BLOB *pac_blob;
krb5_error_code ret;
}
nt_status = samba_kdc_update_pac_blob(mem_ctx, context,
- p->iconv_convenience,
+ p->kdc_db_ctx->ic_ctx,
pac, pac_blob);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Building PAC failed: %s\n",
krb5_error_code ret;
NTSTATUS nt_status;
TALLOC_CTX *tmp_ctx;
- struct hdb_samba4_private *p;
+ struct samba_kdc_entry *p;
char *workstation = NULL;
HostAddresses *addresses = req->req_body.addresses;
int i;
bool password_change;
tmp_ctx = talloc_new(client_ex->ctx);
- p = talloc_get_type(client_ex->ctx, struct hdb_samba4_private);
+ p = talloc_get_type(client_ex->ctx, struct samba_kdc_entry);
if (!tmp_ctx) {
return ENOMEM;
/* we allow all kinds of trusts here */
nt_status = authsam_account_ok(tmp_ctx,
- p->samdb,
+ p->kdc_db_ctx->samdb,
MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT | MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT,
p->realm_dn,
p->msg,