idmap_ctx->lp_ctx = lp_ctx;
- idmap_ctx->ldb_ctx = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx,
+ idmap_ctx->ldb_ctx = ldb_wrap_connect(idmap_ctx, ev_ctx, lp_ctx,
"idmap.ldb",
system_session(lp_ctx),
NULL, 0);
if (idmap_ctx->ldb_ctx == NULL) {
- return NULL;
+ goto fail;
}
- idmap_ctx->unix_groups_sid = dom_sid_parse_talloc(mem_ctx, "S-1-22-2");
+ idmap_ctx->unix_groups_sid = dom_sid_parse_talloc(
+ idmap_ctx, "S-1-22-2");
if (idmap_ctx->unix_groups_sid == NULL) {
- return NULL;
+ goto fail;
}
- idmap_ctx->unix_users_sid = dom_sid_parse_talloc(mem_ctx, "S-1-22-1");
+ idmap_ctx->unix_users_sid = dom_sid_parse_talloc(
+ idmap_ctx, "S-1-22-1");
if (idmap_ctx->unix_users_sid == NULL) {
- return NULL;
+ goto fail;
}
idmap_ctx->samdb = samdb_connect(idmap_ctx, ev_ctx, lp_ctx, system_session(lp_ctx), 0);
if (idmap_ctx->samdb == NULL) {
DEBUG(0, ("Failed to load sam.ldb in idmap_init\n"));
- return NULL;
+ goto fail;
}
return idmap_ctx;
+fail:
+ TALLOC_FREE(idmap_ctx);
+ return NULL;
}
/**
static NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx,
TALLOC_CTX *mem_ctx,
- const struct unixid *unixid,
+ struct unixid *unixid,
struct dom_sid **sid)
{
int ret;
struct ldb_context *ldb = idmap_ctx->ldb_ctx;
struct ldb_result *res = NULL;
struct ldb_message *msg;
- struct dom_sid *unix_sid, *new_sid;
+ const struct dom_sid *unix_sid;
+ struct dom_sid *new_sid;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
const char *id_type;
}
if (res->count == 1) {
+ const char *type = ldb_msg_find_attr_as_string(res->msgs[0],
+ "type", NULL);
+
*sid = idmap_msg_get_dom_sid(mem_ctx, res->msgs[0],
"objectSid");
if (*sid == NULL) {
status = NT_STATUS_NONE_MAPPED;
goto failed;
}
+
+ if (type == NULL) {
+ DEBUG(1, ("Invalid type for mapping entry.\n"));
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NONE_MAPPED;
+ }
+
+ if (strcmp(type, "ID_TYPE_BOTH") == 0) {
+ unixid->type = ID_TYPE_BOTH;
+ } else if (strcmp(type, "ID_TYPE_UID") == 0) {
+ unixid->type = ID_TYPE_UID;
+ } else {
+ unixid->type = ID_TYPE_GID;
+ }
+
talloc_free(tmp_ctx);
return NT_STATUS_OK;
}
/* For local users/groups , we just create a rid = uid/gid */
if (unixid->type == ID_TYPE_UID) {
- unix_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-1");
+ unix_sid = &global_sid_Unix_Users;
} else {
- unix_sid = dom_sid_parse_talloc(tmp_ctx, "S-1-22-2");
- }
- if (unix_sid == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto failed;
+ unix_sid = &global_sid_Unix_Groups;
}
new_sid = dom_sid_add_rid(mem_ctx, unix_sid, unixid->id);