Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

NTSTATUS cli_lsa_lookup_sids ( struct cli_state *  cli,
TALLOC_CTX mem_ctx,
POLICY_HND *  pol,
int  num_sids,
DOM_SID *  sids,
char ***  domains,
char ***  names,
uint32 **  types 
)

Lookup a list of sids

Definition at line 225 of file cli_lsarpc.c.

References talloc(), and talloc_strdup().

{
      prs_struct qbuf, rbuf;
      LSA_Q_LOOKUP_SIDS q;
      LSA_R_LOOKUP_SIDS r;
      DOM_R_REF ref;
      LSA_TRANS_NAME_ENUM t_names;
      NTSTATUS result;
      int i;

      ZERO_STRUCT(q);
      ZERO_STRUCT(r);

      /* Initialise parse structures */

      prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
      prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);

      /* Marshall data and send request */

      init_q_lookup_sids(mem_ctx, &q, pol, num_sids, sids, 1);

      if (!lsa_io_q_lookup_sids("", &q, &qbuf, 0) ||
          !rpc_api_pipe_req(cli, LSA_LOOKUPSIDS, &qbuf, &rbuf)) {
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }

      /* Unmarshall response */

      ZERO_STRUCT(ref);
      ZERO_STRUCT(t_names);

      r.dom_ref = &ref;
      r.names = &t_names;

      if (!lsa_io_r_lookup_sids("", &r, &rbuf, 0)) {
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }

      result = r.status;

      if (!NT_STATUS_IS_OK(result) &&
          NT_STATUS_V(result) != NT_STATUS_V(STATUS_SOME_UNMAPPED)) {
        
            /* An actual error occured */

            goto done;
      }

      /* Return output parameters */

      if (r.mapped_count == 0) {
            result = NT_STATUS_NONE_MAPPED;
            goto done;
      }

      if (!((*domains) = (char **)talloc(mem_ctx, sizeof(char *) *
                                 num_sids))) {
            DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }

      if (!((*names) = (char **)talloc(mem_ctx, sizeof(char *) *
                               num_sids))) {
            DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }

      if (!((*types) = (uint32 *)talloc(mem_ctx, sizeof(uint32) *
                                num_sids))) {
            DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }
            
      for (i = 0; i < num_sids; i++) {
            fstring name, dom_name;
            uint32 dom_idx = t_names.name[i].domain_idx;

            /* Translate optimised name through domain index array */

            if (dom_idx != 0xffffffff) {

                  unistr2_to_unix(dom_name, &ref.ref_dom[dom_idx].uni_dom_name, sizeof(dom_name)- 1);
                  unistr2_to_unix(name, &t_names.uni_name[i], sizeof(name) - 1);

                  (*names)[i] = talloc_strdup(mem_ctx, name);
                  (*domains)[i] = talloc_strdup(mem_ctx, dom_name);
                  (*types)[i] = t_names.name[i].sid_name_use;
                  
                  if (((*names)[i] == NULL) || ((*domains)[i] == NULL)) {
                        DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
                        result = NT_STATUS_UNSUCCESSFUL;
                        goto done;
                  }

            } else {
                  (*names)[i] = NULL;
                  (*types)[i] = SID_NAME_UNKNOWN;
            }
      }

 done:
      prs_mem_free(&qbuf);
      prs_mem_free(&rbuf);

      return result;
}


Generated by  Doxygen 1.6.0   Back to index