#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
#include "libcli/security/security.h"
-#include "util/util_ldb.h"
+#include "../lib/util/util_ldb.h"
#include "param/param.h"
+#include "ldb_wrap.h"
+
+/* connect to the privilege database */
+struct ldb_context *privilege_connect(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev_ctx,
+ struct loadparm_context *lp_ctx)
+{
+ return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, "privilege.ldb",
+ NULL, NULL, 0);
+}
/*
add privilege bits for one sid to a security_token
*/
-static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx,
+static NTSTATUS samdb_privilege_setup_sid(struct ldb_context *pdb, TALLOC_CTX *mem_ctx,
struct security_token *token,
const struct dom_sid *sid)
{
sidstr = ldap_encode_ndr_dom_sid(mem_ctx, sid);
NT_STATUS_HAVE_NO_MEMORY(sidstr);
- ret = gendb_search(samctx, mem_ctx, NULL, &res, attrs, "objectSid=%s", sidstr);
+ ret = gendb_search(pdb, mem_ctx, NULL, &res, attrs, "objectSid=%s", sidstr);
talloc_free(sidstr);
if (ret != 1) {
/* not an error to not match */
setup the privilege mask for this security token based on our
local SAM
*/
-NTSTATUS samdb_privilege_setup(struct loadparm_context *lp_ctx, struct security_token *token)
+NTSTATUS samdb_privilege_setup(struct tevent_context *ev_ctx,
+ struct loadparm_context *lp_ctx, struct security_token *token)
{
- void *samctx;
+ struct ldb_context *pdb;
TALLOC_CTX *mem_ctx;
int i;
NTSTATUS status;
}
mem_ctx = talloc_new(token);
- samctx = samdb_connect(mem_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
- if (samctx == NULL) {
+ pdb = privilege_connect(mem_ctx, ev_ctx, lp_ctx);
+ if (pdb == NULL) {
talloc_free(mem_ctx);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
token->privilege_mask = 0;
for (i=0;i<token->num_sids;i++) {
- status = samdb_privilege_setup_sid(samctx, mem_ctx,
+ status = samdb_privilege_setup_sid(pdb, mem_ctx,
token, token->sids[i]);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);