00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "includes.h"
00023
00024
00025
00026
00027
00028
00029
00030 NTSTATUS rpccli_ds_getprimarydominfo(struct rpc_pipe_client *cli,
00031 TALLOC_CTX *mem_ctx,
00032 uint16 level, DS_DOMINFO_CTR *ctr)
00033 {
00034 prs_struct qbuf, rbuf;
00035 DS_Q_GETPRIMDOMINFO q;
00036 DS_R_GETPRIMDOMINFO r;
00037 NTSTATUS result;
00038
00039 ZERO_STRUCT(q);
00040 ZERO_STRUCT(r);
00041
00042 q.level = level;
00043
00044 CLI_DO_RPC( cli, mem_ctx, PI_LSARPC_DS, DS_GETPRIMDOMINFO,
00045 q, r,
00046 qbuf, rbuf,
00047 ds_io_q_getprimdominfo,
00048 ds_io_r_getprimdominfo,
00049 NT_STATUS_UNSUCCESSFUL);
00050
00051
00052
00053
00054 result = r.status;
00055
00056 if ( r.ptr && ctr ) {
00057 ctr->basic = TALLOC_P(mem_ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC);
00058 if (!ctr->basic)
00059 goto done;
00060 memcpy(ctr->basic, r.info.basic, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
00061 }
00062
00063 done:
00064
00065 return result;
00066 }
00067
00068
00069
00070
00071
00072 NTSTATUS rpccli_ds_enum_domain_trusts(struct rpc_pipe_client *cli,
00073 TALLOC_CTX *mem_ctx,
00074 const char *server, uint32 flags,
00075 struct ds_domain_trust **trusts,
00076 uint32 *num_domains)
00077 {
00078 prs_struct qbuf, rbuf;
00079 DS_Q_ENUM_DOM_TRUSTS q;
00080 DS_R_ENUM_DOM_TRUSTS r;
00081 NTSTATUS result;
00082
00083 ZERO_STRUCT(q);
00084 ZERO_STRUCT(r);
00085
00086 init_q_ds_enum_domain_trusts( &q, server, flags );
00087
00088 CLI_DO_RPC( cli, mem_ctx, PI_NETLOGON, DS_ENUM_DOM_TRUSTS,
00089 q, r,
00090 qbuf, rbuf,
00091 ds_io_q_enum_domain_trusts,
00092 ds_io_r_enum_domain_trusts,
00093 NT_STATUS_UNSUCCESSFUL);
00094
00095 result = r.status;
00096
00097 if ( NT_STATUS_IS_OK(result) ) {
00098 int i;
00099
00100 *num_domains = r.num_domains;
00101 if (r.num_domains) {
00102 *trusts = TALLOC_ARRAY(mem_ctx, struct ds_domain_trust, r.num_domains);
00103
00104 if (*trusts == NULL) {
00105 return NT_STATUS_NO_MEMORY;
00106 }
00107 } else {
00108 *trusts = NULL;
00109 }
00110
00111 for ( i=0; i< *num_domains; i++ ) {
00112 (*trusts)[i].flags = r.domains.trusts[i].flags;
00113 (*trusts)[i].parent_index = r.domains.trusts[i].parent_index;
00114 (*trusts)[i].trust_type = r.domains.trusts[i].trust_type;
00115 (*trusts)[i].trust_attributes = r.domains.trusts[i].trust_attributes;
00116 (*trusts)[i].guid = r.domains.trusts[i].guid;
00117
00118 if (r.domains.trusts[i].sid_ptr) {
00119 sid_copy(&(*trusts)[i].sid, &r.domains.trusts[i].sid.sid);
00120 } else {
00121 ZERO_STRUCT((*trusts)[i].sid);
00122 }
00123
00124 if (r.domains.trusts[i].netbios_ptr) {
00125 (*trusts)[i].netbios_domain = unistr2_tdup( mem_ctx, &r.domains.trusts[i].netbios_domain );
00126 } else {
00127 (*trusts)[i].netbios_domain = NULL;
00128 }
00129
00130 if (r.domains.trusts[i].dns_ptr) {
00131 (*trusts)[i].dns_domain = unistr2_tdup( mem_ctx, &r.domains.trusts[i].dns_domain );
00132 } else {
00133 (*trusts)[i].dns_domain = NULL;
00134 }
00135 }
00136 }
00137
00138 return result;
00139 }