}
ret = ldb_search(ldb, dn, &res, dn, LDB_SCOPE_BASE, NULL, NULL);
- if (ret != LDB_SUCCESS || res == NULL || res->count != 1) {
+ if (ret != LDB_SUCCESS || res->count != 1) {
goto failed;
}
ret = ldb_search(ldb, talloc_tos(), &res, NULL, LDB_SCOPE_SUBTREE,
NULL, "(&(gidNumber=%u)(objectClass=groupMap))",
(unsigned)gid);
- if (ret != LDB_SUCCESS || res == NULL || res->count != 1) {
+ if (ret != LDB_SUCCESS || res->count != 1) {
goto failed;
}
ret = ldb_search(ldb, talloc_tos(), &res, NULL, LDB_SCOPE_SUBTREE,
NULL, "(&(ntName=%s)(objectClass=groupMap))", name);
- if (ret != LDB_SUCCESS || res == NULL || res->count != 1) {
+ if (ret != LDB_SUCCESS || res->count != 1) {
goto failed;
}
sid_name_use);
}
- if (ret != LDB_SUCCESS || res == NULL) goto failed;
+ if (ret != LDB_SUCCESS) goto failed;
(*pp_rmap) = NULL;
*p_num_entries = 0;
ret = ldb_search(ldb, talloc_tos(), &res, NULL, LDB_SCOPE_SUBTREE,
attrs, "(&(member=%s)(objectClass=groupMap))",
string_sid);
- if (ret != LDB_SUCCESS || res == NULL) {
+ if (ret != LDB_SUCCESS) {
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
goto failed;
}
/*
enumerate sids that have the given alias set in member
*/
-static NTSTATUS enum_aliasmem(const DOM_SID *alias, DOM_SID **sids, size_t *num)
+static NTSTATUS enum_aliasmem(const DOM_SID *alias, TALLOC_CTX *mem_ctx,
+ DOM_SID **sids, size_t *num)
{
const char *attrs[] = {
"member",
}
ret = ldb_search(ldb, ldb, &res, dn, LDB_SCOPE_BASE, attrs, NULL);
- talloc_steal(dn, res);
- if (ret == LDB_SUCCESS && res && res->count == 0) {
+ if (ret == LDB_SUCCESS && res->count == 0) {
+ talloc_free(res);
talloc_free(dn);
return NT_STATUS_OK;
}
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
+ talloc_steal(dn, res);
el = ldb_msg_find_element(res->msgs[0], "member");
if (el == NULL) {
talloc_free(dn);
- return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ return NT_STATUS_OK;
}
for (i=0;i<el->num_values;i++) {
DOM_SID sid;
string_to_sid(&sid, (const char *)el->values[i].data);
- status = add_sid_to_array_unique(NULL, &sid, sids, num);
+ status = add_sid_to_array_unique(mem_ctx, &sid, sids, num);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}