1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

samdb: Add flags argument to samdb_connect().

This commit is contained in:
Jelmer Vernooij 2010-10-10 17:00:45 +02:00
parent 6280725b47
commit 93126b3315
23 changed files with 48 additions and 48 deletions

View File

@ -447,7 +447,7 @@ _PUBLIC_ NTSTATUS auth_context_create_methods(TALLOC_CTX *mem_ctx, const char **
if (sam_ctx) {
ctx->sam_ctx = sam_ctx;
} else {
ctx->sam_ctx = samdb_connect(ctx, ctx->event_ctx, ctx->lp_ctx, system_session(ctx->lp_ctx));
ctx->sam_ctx = samdb_connect(ctx, ctx->event_ctx, ctx->lp_ctx, system_session(ctx->lp_ctx), 0);
}
for (i=0; methods[i] ; i++) {

View File

@ -212,7 +212,7 @@ static void cldapd_task_init(struct task_server *task)
}
cldapd->task = task;
cldapd->samctx = samdb_connect(cldapd, task->event_ctx, task->lp_ctx, system_session(task->lp_ctx));
cldapd->samctx = samdb_connect(cldapd, task->event_ctx, task->lp_ctx, system_session(task->lp_ctx), 0);
if (cldapd->samctx == NULL) {
task_server_terminate(task, "cldapd failed to open samdb", true);
return;

View File

@ -575,7 +575,7 @@ static void dnsupdate_task_init(struct task_server *task)
}
service->samdb = samdb_connect(service, service->task->event_ctx, task->lp_ctx,
service->system_session_info);
service->system_session_info, 0);
if (!service->samdb) {
task_server_terminate(task, "dnsupdate: Failed to connect to local samdb\n",
true);

View File

@ -55,7 +55,7 @@ static WERROR kccsrv_connect_samdb(struct kccsrv_service *service, struct loadpa
{
const struct GUID *ntds_guid;
service->samdb = samdb_connect(service, service->task->event_ctx, lp_ctx, service->system_session_info);
service->samdb = samdb_connect(service, service->task->event_ctx, lp_ctx, service->system_session_info, 0);
if (!service->samdb) {
return WERR_DS_UNAVAILABLE;
}

View File

@ -65,7 +65,7 @@ static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service, struct lo
const struct GUID *ntds_guid;
struct drsuapi_DsBindInfo28 *bind_info28;
service->samdb = samdb_connect(service, service->task->event_ctx, lp_ctx, service->system_session_info);
service->samdb = samdb_connect(service, service->task->event_ctx, lp_ctx, service->system_session_info, 0);
if (!service->samdb) {
return WERR_DS_UNAVAILABLE;
}

View File

@ -1235,7 +1235,7 @@ NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
ldb = samdb_connect(mem_ctx, ev_ctx, lp_ctx, system_session(lp_ctx));
ldb = samdb_connect(mem_ctx, ev_ctx, lp_ctx, system_session(lp_ctx), 0);
if (ldb == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}

View File

@ -123,14 +123,15 @@ struct cli_credentials *samdb_credentials(struct tevent_context *event_ctx,
struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
struct tevent_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info *session_info)
struct auth_session_info *session_info,
int flags)
{
struct ldb_context *ldb;
struct dsdb_schema *schema;
ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx,
lpcfg_sam_url(lp_ctx), session_info,
samdb_credentials(ev_ctx, lp_ctx),
0);
flags);
if (!ldb) {
return NULL;

View File

@ -1660,7 +1660,7 @@ NTSTATUS samba_kdc_setup_db_ctx(TALLOC_CTX *mem_ctx, struct samba_kdc_base_conte
/* Setup the link to LDB */
kdc_db_ctx->samdb = samdb_connect(kdc_db_ctx, base_ctx->ev_ctx,
base_ctx->lp_ctx, session_info);
base_ctx->lp_ctx, session_info, 0);
if (kdc_db_ctx->samdb == NULL) {
DEBUG(1, ("hdb_samba4_create: Cannot open samdb for KDC backend!"));
talloc_free(kdc_db_ctx);

View File

@ -180,7 +180,7 @@ static bool kpasswdd_change_password(struct kdc_server *kdc,
/* Connect to a SAMDB with system privileges for fetching the old pw
* hashes. */
samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx,
system_session(kdc->task->lp_ctx));
system_session(kdc->task->lp_ctx), 0);
if (!samdb) {
return kpasswdd_make_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR,
@ -213,7 +213,7 @@ static bool kpasswdd_change_password(struct kdc_server *kdc,
/* Start a SAM with user privileges for the password change */
samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx,
session_info);
session_info, 0);
if (!samdb) {
return kpasswdd_make_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR,
@ -371,7 +371,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
}
krb5_free_principal(context, principal);
samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx, session_info);
samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx, session_info, 0);
if (!samdb) {
return kpasswdd_make_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR,

View File

@ -194,12 +194,10 @@ static int map_ldb_error(TALLOC_CTX *mem_ctx, int ldb_err,
*/
NTSTATUS ldapsrv_backend_Init(struct ldapsrv_connection *conn)
{
conn->ldb = ldb_wrap_connect(conn,
conn->ldb = samdb_connect(conn,
conn->connection->event.ctx,
conn->lp_ctx,
lpcfg_sam_url(conn->lp_ctx),
conn->session_info,
samdb_credentials(conn->connection->event.ctx, conn->lp_ctx),
conn->global_catalog ? LDB_FLG_RDONLY : 0);
if (conn->ldb == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;

View File

@ -841,7 +841,7 @@ static NTSTATUS add_socket(struct tevent_context *event_context,
/* Load LDAP database, but only to read our settings */
ldb = samdb_connect(ldap_service, ldap_service->task->event_ctx,
lp_ctx, system_session(lp_ctx));
lp_ctx, system_session(lp_ctx), 0);
if (!ldb) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}

View File

@ -1216,7 +1216,8 @@ NTSTATUS libnet_samsync_ldb(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, str
state->sam_ldb = samdb_connect(mem_ctx,
ctx->event_ctx,
ctx->lp_ctx,
r->in.session_info);
r->in.session_info,
0);
if (!state->sam_ldb) {
return NT_STATUS_INTERNAL_DB_ERROR;
}

View File

@ -66,7 +66,7 @@ static void nbtd_task_init(struct task_server *task)
return;
}
nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->event_ctx, task->lp_ctx, system_session(task->lp_ctx));
nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->event_ctx, task->lp_ctx, system_session(task->lp_ctx), 0);
if (nbtsrv->sam_ctx == NULL) {
task_server_terminate(task, "nbtd failed to open samdb", true);
return;

View File

@ -1013,7 +1013,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx,
h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, lock_path(h, lp_ctx, lpcfg_wins_url(lp_ctx)),
NULL, NULL, flags);
if (!h->ldb) goto failed;
if (!h->ldb) goto failed;
h->caller = caller;
h->hook_script = lpcfg_wins_hook(lp_ctx);

View File

@ -520,7 +520,7 @@ static void ntp_signd_task_init(struct task_server *task)
ntp_signd->task = task;
/* Must be system to get at the password hashes */
ntp_signd->samdb = samdb_connect(ntp_signd, task->event_ctx, task->lp_ctx, system_session(task->lp_ctx));
ntp_signd->samdb = samdb_connect(ntp_signd, task->event_ctx, task->lp_ctx, system_session(task->lp_ctx), 0);
if (ntp_signd->samdb == NULL) {
task_server_terminate(task, "ntp_signd failed to open samdb", true);
return;

View File

@ -95,7 +95,7 @@ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct tevent_contex
break;
}
/* open main ldb */
samctx = samdb_connect(tmp_ctx, event_ctx, dce_ctx->lp_ctx, anonymous_session(tmp_ctx, dce_ctx->lp_ctx));
samctx = samdb_connect(tmp_ctx, event_ctx, dce_ctx->lp_ctx, anonymous_session(tmp_ctx, dce_ctx->lp_ctx), 0);
if (samctx == NULL) {
DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
} else {

View File

@ -80,7 +80,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
* connect to the samdb
*/
b_state->sam_ctx = samdb_connect(b_state, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx, auth_info);
dce_call->conn->dce_ctx->lp_ctx, auth_info, 0);
if (!b_state->sam_ctx) {
return WERR_FOOBAR;
}
@ -95,7 +95,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
if (W_ERROR_IS_OK(werr)) {
b_state->sam_ctx_system = samdb_connect(b_state, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
system_session(dce_call->conn->dce_ctx->lp_ctx));
system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (!b_state->sam_ctx_system) {
return WERR_FOOBAR;
}

View File

@ -2884,7 +2884,7 @@ static NTSTATUS dcesrv_lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALL
name = &r->in.name.string[2];
/* We need to connect to the database as system, as this is one of the rare RPC calls that must read the secrets (and this is denied otherwise) */
secret_state->sam_ldb = talloc_reference(secret_state,
samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx)));
samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx), 0));
secret_state->global = true;
if (strlen(name) < 1) {
@ -3021,7 +3021,7 @@ static NTSTATUS dcesrv_lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC
name = &r->in.name.string[2];
/* We need to connect to the database as system, as this is one of the rare RPC calls that must read the secrets (and this is denied otherwise) */
secret_state->sam_ldb = talloc_reference(secret_state,
samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx)));
samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx), 0));
secret_state->global = true;
if (strlen(name) < 1) {

View File

@ -43,7 +43,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
}
/* make sure the sam database is accessible */
state->sam_ldb = samdb_connect(state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
state->sam_ldb = samdb_connect(state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info, 0);
if (state->sam_ldb == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}

View File

@ -131,7 +131,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
}
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
system_session(dce_call->conn->dce_ctx->lp_ctx));
system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -400,7 +400,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet(struct dcesrv_call_state *dce_call
&creds);
NT_STATUS_NOT_OK_RETURN(nt_status);
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx));
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -458,7 +458,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal
&creds);
NT_STATUS_NOT_OK_RETURN(nt_status);
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx));
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -942,7 +942,7 @@ static WERROR dcesrv_netr_GetDcName(struct dcesrv_call_state *dce_call, TALLOC_C
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_DS_UNAVAILABLE;
}
@ -1057,7 +1057,7 @@ static WERROR dcesrv_netr_GetAnyDCName(struct dcesrv_call_state *dce_call, TALLO
}
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_DS_UNAVAILABLE;
}
@ -1184,7 +1184,7 @@ static WERROR dcesrv_netr_DsRGetSiteName(struct dcesrv_call_state *dce_call, TAL
struct loadparm_context *lp_ctx = dce_call->conn->dce_ctx->lp_ctx;
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_DS_UNAVAILABLE;
}
@ -1293,7 +1293,7 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
system_session(dce_call->conn->dce_ctx->lp_ctx));
system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -1557,7 +1557,7 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call,
ZERO_STRUCTP(r->out.info);
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_DS_UNAVAILABLE;
}
@ -1708,7 +1708,7 @@ static WERROR dcesrv_netr_DsRAddressToSitenamesExW(struct dcesrv_call_state *dce
uint32_t i;
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_DS_UNAVAILABLE;
}
@ -1824,7 +1824,7 @@ static WERROR dcesrv_netr_DsrGetDcSiteCoverageW(struct dcesrv_call_state *dce_ca
struct loadparm_context *lp_ctx = dce_call->conn->dce_ctx->lp_ctx;
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_DS_UNAVAILABLE;
}
@ -2003,7 +2003,7 @@ static WERROR dcesrv_netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce
r->out.trusts = trusts;
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_GENERAL_FAILURE;
}
@ -2153,7 +2153,7 @@ static WERROR dcesrv_netr_DsRGetForestTrustInformation(struct dcesrv_call_state
}
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return WERR_GENERAL_FAILURE;
}
@ -2223,7 +2223,7 @@ static NTSTATUS dcesrv_netr_GetForestTrustInformation(struct dcesrv_call_state *
}
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return NT_STATUS_UNSUCCESSFUL;
}

View File

@ -173,7 +173,7 @@ static NTSTATUS dcesrv_samr_Connect(struct dcesrv_call_state *dce_call, TALLOC_C
}
/* make sure the sam database is accessible */
c_state->sam_ctx = samdb_connect(c_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
c_state->sam_ctx = samdb_connect(c_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info, 0);
if (c_state->sam_ctx == NULL) {
talloc_free(c_state);
return NT_STATUS_INVALID_SYSTEM_SERVICE;
@ -4098,7 +4098,7 @@ static NTSTATUS dcesrv_samr_GetDomPwInfo(struct dcesrv_call_state *dce_call, TAL
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}

View File

@ -64,7 +64,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call,
* hashes. */
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
system_session(dce_call->conn->dce_ctx->lp_ctx));
system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -120,7 +120,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call,
/* Start a SAM with user privileges for the password change */
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -198,7 +198,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
* hashes. */
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
system_session(dce_call->conn->dce_ctx->lp_ctx));
system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -261,7 +261,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
/* Connect to a SAMDB with user privileges for the password change */
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -335,7 +335,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
* hashes. */
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
system_session(dce_call->conn->dce_ctx->lp_ctx));
system_session(dce_call->conn->dce_ctx->lp_ctx), 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@ -413,7 +413,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
/* Connect to a SAMDB with user privileges for the password change */
sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->auth_state.session_info);
dce_call->conn->auth_state.session_info, 0);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}

View File

@ -1627,7 +1627,7 @@ static NTSTATUS trans2_getdfsreferral(struct smbsrv_request *req,
context = talloc_new(req);
NT_STATUS_HAVE_NO_MEMORY(context);
ldb = samdb_connect(context, req->tcon->ntvfs->event_ctx, lp_ctx, system_session(lp_ctx));
ldb = samdb_connect(context, req->tcon->ntvfs->event_ctx, lp_ctx, system_session(lp_ctx), 0);
if (ldb == NULL) {
DEBUG(2,(__location__ ": Failed to open samdb\n"));
talloc_free(context);