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

NTSTATUS cli_lsa_enum_sids ( struct cli_state *  cli,
TALLOC_CTX mem_ctx,
POLICY_HND *  pol,
uint32 *  enum_ctx,
uint32  pref_max_length,
uint32 *  num_sids,
DOM_SID **  sids 
)

Enumerate list of SIDs

Definition at line 767 of file cli_lsarpc.c.

References talloc().

{
      prs_struct qbuf, rbuf;
      LSA_Q_ENUM_ACCOUNTS q;
      LSA_R_ENUM_ACCOUNTS r;
      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_lsa_q_enum_accounts(&q, pol, *enum_ctx, pref_max_length);

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

      /* Unmarshall response */

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

      result = r.status;

      if (!NT_STATUS_IS_OK(result = r.status)) {
            goto done;
      }

      if (r.sids.num_entries==0)
            goto done;

      /* Return output parameters */

      *sids = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID) * r.sids.num_entries);
      if (!*sids) {
            DEBUG(0, ("(cli_lsa_enum_sids): out of memory\n"));
            result = NT_STATUS_UNSUCCESSFUL;
            goto done;
      }

      /* Copy across names and sids */

      for (i = 0; i < r.sids.num_entries; i++) {
            sid_copy(&(*sids)[i], &r.sids.sid[i].sid);
      }

      *num_sids= r.sids.num_entries;
      *enum_ctx = r.enum_context;

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

      return result;
}


Generated by  Doxygen 1.6.0   Back to index