*/
#include "includes.h"
+#include "../librpc/gen_ndr/cli_lsa.h"
+#include "rpc_client/cli_lsarpc.h"
+#include "rpc_client/init_lsa.h"
+#include "../libcli/security/security.h"
/** @defgroup lsa LSA - Local Security Architecture
* @ingroup rpc_client
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
- const DOM_SID *sids,
+ const struct dom_sid *sids,
char **domains,
char **names,
enum lsa_SidType *types,
}
for (i = 0; i<num_sids; i++) {
- sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[i]);
+ sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sids[i]);
if (!sid_array.sids[i].sid) {
return NT_STATUS_NO_MEMORY;
}
name = lsa_names.names[i].name.string;
if (name) {
- (names)[i] = talloc_strdup(mem_ctx, name);
+ (names)[i] = talloc_strdup(names, name);
if ((names)[i] == NULL) {
DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
result = NT_STATUS_UNSUCCESSFUL;
} else {
(names)[i] = NULL;
}
- (domains)[i] = talloc_strdup(mem_ctx, dom_name);
+ domains[i] = talloc_strdup(domains,
+ dom_name ? dom_name : "");
(types)[i] = lsa_names.names[i].sid_type;
if (((domains)[i] == NULL)) {
DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
- const DOM_SID *sids,
+ const struct dom_sid *sids,
char ***pdomains,
char ***pnames,
enum lsa_SidType **ptypes,
NTSTATUS result = NT_STATUS_OK;
int sids_left = 0;
int sids_processed = 0;
- const DOM_SID *hunk_sids = sids;
+ const struct dom_sid *hunk_sids = sids;
char **hunk_domains;
char **hunk_names;
enum lsa_SidType *hunk_types;
char **domains = NULL;
char **names = NULL;
enum lsa_SidType *types = NULL;
+ bool have_mapped = false;
+ bool have_unmapped = false;
if (num_sids) {
if (!(domains = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
goto fail;
}
- /* adapt overall result */
- if (( NT_STATUS_IS_OK(result) &&
- !NT_STATUS_IS_OK(hunk_result))
- ||
- ( NT_STATUS_EQUAL(result, NT_STATUS_NONE_MAPPED) &&
- !NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED)))
- {
- result = STATUS_SOME_UNMAPPED;
+ if (NT_STATUS_IS_OK(hunk_result)) {
+ have_mapped = true;
+ }
+ if (NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED)) {
+ have_unmapped = true;
+ }
+ if (NT_STATUS_EQUAL(hunk_result, STATUS_SOME_UNMAPPED)) {
+ int i;
+ for (i=0; i<hunk_num_sids; i++) {
+ if (hunk_types[i] == SID_NAME_UNKNOWN) {
+ have_unmapped = true;
+ } else {
+ have_mapped = true;
+ }
+ }
}
sids_left -= hunk_num_sids;
*pdomains = domains;
*pnames = names;
*ptypes = types;
- return result;
+
+ if (!have_mapped) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+ if (have_unmapped) {
+ return STATUS_SOME_UNMAPPED;
+ }
+ return NT_STATUS_OK;
fail:
TALLOC_FREE(domains);
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
- const DOM_SID *sids,
+ const struct dom_sid *sids,
char ***pdomains,
char ***pnames,
enum lsa_SidType **ptypes)
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
- const DOM_SID *sids,
+ const struct dom_sid *sids,
char ***pdomains,
char ***pnames,
enum lsa_SidType **ptypes)
const char **names,
const char ***dom_names,
int level,
- DOM_SID **sids,
+ struct dom_sid **sids,
enum lsa_SidType **types,
bool use_lookupnames4)
{
}
if (num_names) {
- if (!((*sids = TALLOC_ARRAY(mem_ctx, DOM_SID, num_names)))) {
+ if (!((*sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, num_names)))) {
DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
for (i = 0; i < num_names; i++) {
uint32_t dom_idx;
- DOM_SID *sid = &(*sids)[i];
+ struct dom_sid *sid = &(*sids)[i];
if (use_lookupnames4) {
dom_idx = sid_array3.sids[i].sid_index;
const char **names,
const char ***dom_names,
int level,
- DOM_SID **sids,
+ struct dom_sid **sids,
enum lsa_SidType **types)
{
return rpccli_lsa_lookup_names_generic(cli, mem_ctx, pol, num_names,
const char **names,
const char ***dom_names,
int level,
- DOM_SID **sids,
+ struct dom_sid **sids,
enum lsa_SidType **types)
{
return rpccli_lsa_lookup_names_generic(cli, mem_ctx, pol, num_names,