NTSTATUS idmap_sids_to_xids(struct idmap_context *idmap_ctx,
			    TALLOC_CTX *mem_ctx,
			    struct id_map **id)
{
	unsigned int i, error_count = 0;
	NTSTATUS status;

	for (i = 0; id && id[i]; i++) {
		status = idmap_sid_to_xid(idmap_ctx, mem_ctx,
					  id[i]->sid, &id[i]->xid);
		if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
			status = idmap_sid_to_xid(idmap_ctx, mem_ctx,
						  id[i]->sid,
						  &id[i]->xid);
		}
		if (!NT_STATUS_IS_OK(status)) {
			struct dom_sid_buf buf;
			DEBUG(1, ("idmapping sid_to_xid failed for id[%d]=%s: %s\n",
				  i,
				  dom_sid_str_buf(id[i]->sid, &buf),
				  nt_errstr(status)));
			error_count++;
			id[i]->status = ID_UNMAPPED;
		} else {
			id[i]->status = ID_MAPPED;
		}
	}

	if (error_count == i) {
		/* Mapping did not work at all. */
		return NT_STATUS_NONE_MAPPED;
	} else if (error_count > 0) {
		/* Some mappings worked, some did not. */
		return STATUS_SOME_UNMAPPED;
	} else {
		return NT_STATUS_OK;
	}
}
NTSTATUS idmap_sids_to_xids(struct idmap_context *idmap_ctx,
			    TALLOC_CTX *mem_ctx,
			    struct id_map **id)
{
	unsigned int i, error_count = 0;
	NTSTATUS status;

	for (i = 0; id && id[i]; i++) {
		status = idmap_sid_to_xid(idmap_ctx, mem_ctx,
					  id[i]->sid, &id[i]->xid);
		if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
			status = idmap_sid_to_xid(idmap_ctx, mem_ctx,
						  id[i]->sid,
						  &id[i]->xid);
		}
		if (!NT_STATUS_IS_OK(status)) {
			struct dom_sid_buf buf;
			DEBUG(1, ("idmapping sid_to_xid failed for id[%d]=%s: %s\n",
				  i,
				  dom_sid_str_buf(id[i]->sid, &buf),
				  nt_errstr(status)));
			error_count++;
			id[i]->status = ID_UNMAPPED;
		} else {
			id[i]->status = ID_MAPPED;
		}
	}

	if (error_count == i) {
		 
		return NT_STATUS_NONE_MAPPED;
	} else if (error_count > 0) {
		 
		return STATUS_SOME_UNMAPPED;
	} else {
		return NT_STATUS_OK;
	}
}