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

NTSTATUS cli_lsa_lookup_names ( struct cli_state *  cli,
TALLOC_CTX mem_ctx,
POLICY_HND *  pol,
int  num_names,
const char **  names,
DOM_SID **  sids,
uint32 **  types 
)

Lookup a list of names

Definition at line 345 of file cli_lsarpc.c.

References talloc().

{
      prs_struct qbuf, rbuf;
      LSA_Q_LOOKUP_NAMES q;
      LSA_R_LOOKUP_NAMES r;
      DOM_R_REF ref;
      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 */

      /* This call converts from UNIX to DOS charset then to unicode. */
      init_q_lookup_names(mem_ctx, &q, pol, num_names, names);

      if (!lsa_io_q_lookup_names("", &q, &qbuf, 0) ||
          !rpc_api_pipe_req(cli, LSA_LOOKUPNAMES, &qbuf, &rbuf)) {
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }
      
      /* Unmarshall response */

      ZERO_STRUCT(ref);
      r.dom_ref = &ref;

      if (!lsa_io_r_lookup_names("", &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 (!((*sids = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID) *
                               num_names)))) {
            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_names)))) {
            DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }

      for (i = 0; i < num_names; i++) {
            DOM_RID2 *t_rids = r.dom_rid;
            uint32 dom_idx = t_rids[i].rid_idx;
            uint32 dom_rid = t_rids[i].rid;
            DOM_SID *sid = &(*sids)[i];

            /* Translate optimised sid through domain index array */

            if (dom_idx != 0xffffffff) {

                  sid_copy(sid, &ref.ref_dom[dom_idx].ref_dom.sid);

                  if (dom_rid != 0xffffffff) {
                        sid_append_rid(sid, dom_rid);
                  }

                  (*types)[i] = t_rids[i].type;
            } else {
                  ZERO_STRUCTP(sid);
                  (*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