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

NTSTATUS cli_lsa_enum_trust_dom ( struct cli_state *  cli,
TALLOC_CTX mem_ctx,
POLICY_HND *  pol,
uint32 *  enum_ctx,
uint32 *  num_domains,
char ***  domain_names,
DOM_SID **  domain_sids 
)

Enumerate list of trusted domains

Definition at line 538 of file cli_lsarpc.c.

References talloc(), and talloc_strdup().

{
      prs_struct qbuf, rbuf;
      LSA_Q_ENUM_TRUST_DOM q;
      LSA_R_ENUM_TRUST_DOM 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_q_enum_trust_dom(&q, pol, *enum_ctx, 0xffffffff);

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

      /* Unmarshall response */

      if (!lsa_io_r_enum_trust_dom("", &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(NT_STATUS_NO_MORE_ENTRIES)) {

            /* An actual error ocured */

            goto done;
      }

      result = NT_STATUS_OK;

      /* Return output parameters */

      if (r.num_domains) {

            /* Allocate memory for trusted domain names and sids */

            *domain_names = (char **)talloc(mem_ctx, sizeof(char *) *
                                    r.num_domains);

            if (!*domain_names) {
                  DEBUG(0, ("cli_lsa_enum_trust_dom(): out of memory\n"));
                  result = NT_STATUS_UNSUCCESSFUL;
                  goto done;
            }

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

            /* Copy across names and sids */

            for (i = 0; i < r.num_domains; i++) {
                  fstring tmp;

                  unistr2_to_unix(tmp, &r.uni_domain_name[i], 
                               sizeof(tmp) - 1);
                  (*domain_names)[i] = talloc_strdup(mem_ctx, tmp);
                  sid_copy(&(*domain_sids)[i], &r.domain_sid[i].sid);
            }
      }

      *num_domains = r.num_domains;
      *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