rpc_client/cli_ds.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    RPC pipe client
00004    Copyright (C) Gerald Carter                        2002,
00005    Copyright (C) Jeremy Allison                         2005.
00006    
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011    
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016    
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 #include "includes.h"
00023 
00024 /* implementations of client side DsXXX() functions */
00025 
00026 /********************************************************************
00027  Get information about the server and directory services
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         /* Return basic info - if we are requesting at info != 1 then
00052            there could be trouble. */ 
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  Enumerate trusted domains in an AD forest
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 }

Sambaに対してSat Aug 29 21:23:15 2009に生成されました。  doxygen 1.4.7