rpc_parse/parse_net.c

説明を見る。
00001 /* 
00002  *  Unix SMB/CIFS implementation.
00003  *  RPC Pipe client / server routines
00004  *  Copyright (C) Andrew Tridgell              1992-1997,
00005  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
00006  *  Copyright (C) Paul Ashton                       1997.
00007  *  Copyright (C) Jean Francois Micouleau           2002.
00008  *
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *  
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *  
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022  */
00023 
00024 #include "includes.h"
00025 
00026 #undef DBGC_CLASS
00027 #define DBGC_CLASS DBGC_RPC_PARSE
00028 
00029 /*******************************************************************
00030  Reads or writes a structure.
00031 ********************************************************************/
00032 
00033 static BOOL net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, int depth)
00034 {
00035         if (neg == NULL)
00036                 return False;
00037 
00038         prs_debug(ps, depth, desc, "net_io_neg_flags");
00039         depth++;
00040 
00041         if(!prs_align(ps))
00042                 return False;
00043         
00044         if(!prs_uint32("neg_flags", ps, depth, &neg->neg_flags))
00045                 return False;
00046 
00047         return True;
00048 }
00049 
00050 /*******************************************************************
00051  Inits a NETLOGON_INFO_3 structure.
00052 ********************************************************************/
00053 
00054 static void init_netinfo_3(NETLOGON_INFO_3 *info, uint32 flags, uint32 logon_attempts)
00055 {
00056         info->flags          = flags;
00057         info->logon_attempts = logon_attempts;
00058         info->reserved_1     = 0x0;
00059         info->reserved_2     = 0x0;
00060         info->reserved_3     = 0x0;
00061         info->reserved_4     = 0x0;
00062         info->reserved_5     = 0x0;
00063 }
00064 
00065 /*******************************************************************
00066  Reads or writes a NETLOGON_INFO_3 structure.
00067 ********************************************************************/
00068 
00069 static BOOL net_io_netinfo_3(const char *desc,  NETLOGON_INFO_3 *info, prs_struct *ps, int depth)
00070 {
00071         if (info == NULL)
00072                 return False;
00073 
00074         prs_debug(ps, depth, desc, "net_io_netinfo_3");
00075         depth++;
00076 
00077         if(!prs_align(ps))
00078                 return False;
00079 
00080         if(!prs_uint32("flags         ", ps, depth, &info->flags))
00081                 return False;
00082         if(!prs_uint32("logon_attempts", ps, depth, &info->logon_attempts))
00083                 return False;
00084         if(!prs_uint32("reserved_1    ", ps, depth, &info->reserved_1))
00085                 return False;
00086         if(!prs_uint32("reserved_2    ", ps, depth, &info->reserved_2))
00087                 return False;
00088         if(!prs_uint32("reserved_3    ", ps, depth, &info->reserved_3))
00089                 return False;
00090         if(!prs_uint32("reserved_4    ", ps, depth, &info->reserved_4))
00091                 return False;
00092         if(!prs_uint32("reserved_5    ", ps, depth, &info->reserved_5))
00093                 return False;
00094 
00095         return True;
00096 }
00097 
00098 
00099 /*******************************************************************
00100  Inits a NETLOGON_INFO_1 structure.
00101 ********************************************************************/
00102 
00103 static void init_netinfo_1(NETLOGON_INFO_1 *info, uint32 flags, uint32 pdc_status)
00104 {
00105         info->flags      = flags;
00106         info->pdc_status = pdc_status;
00107 }
00108 
00109 /*******************************************************************
00110  Reads or writes a NETLOGON_INFO_1 structure.
00111 ********************************************************************/
00112 
00113 static BOOL net_io_netinfo_1(const char *desc, NETLOGON_INFO_1 *info, prs_struct *ps, int depth)
00114 {
00115         if (info == NULL)
00116                 return False;
00117 
00118         prs_debug(ps, depth, desc, "net_io_netinfo_1");
00119         depth++;
00120 
00121         if(!prs_align(ps))
00122                 return False;
00123         
00124         if(!prs_uint32("flags     ", ps, depth, &info->flags))
00125                 return False;
00126         if(!prs_uint32("pdc_status", ps, depth, &info->pdc_status))
00127                 return False;
00128 
00129         return True;
00130 }
00131 
00132 /*******************************************************************
00133  Inits a NETLOGON_INFO_2 structure.
00134 ********************************************************************/
00135 
00136 static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status,
00137                                 uint32 tc_status, const char *trusted_dc_name)
00138 {
00139         info->flags      = flags;
00140         info->pdc_status = pdc_status;
00141         info->ptr_trusted_dc_name = 1;
00142         info->tc_status  = tc_status;
00143 
00144         if (trusted_dc_name != NULL)
00145                 init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, UNI_STR_TERMINATE);
00146         else
00147                 init_unistr2(&info->uni_trusted_dc_name, "", UNI_STR_TERMINATE);
00148 }
00149 
00150 /*******************************************************************
00151  Reads or writes a NETLOGON_INFO_2 structure.
00152 ********************************************************************/
00153 
00154 static BOOL net_io_netinfo_2(const char *desc, NETLOGON_INFO_2 *info, prs_struct *ps, int depth)
00155 {
00156         if (info == NULL)
00157                 return False;
00158 
00159         prs_debug(ps, depth, desc, "net_io_netinfo_2");
00160         depth++;
00161 
00162         if(!prs_align(ps))
00163                 return False;
00164         
00165         if(!prs_uint32("flags              ", ps, depth, &info->flags))
00166                 return False;
00167         if(!prs_uint32("pdc_status         ", ps, depth, &info->pdc_status))
00168                 return False;
00169         if(!prs_uint32("ptr_trusted_dc_name", ps, depth, &info->ptr_trusted_dc_name))
00170                 return False;
00171         if(!prs_uint32("tc_status          ", ps, depth, &info->tc_status))
00172                 return False;
00173 
00174         if (info->ptr_trusted_dc_name != 0) {
00175                 if(!smb_io_unistr2("unistr2", &info->uni_trusted_dc_name, info->ptr_trusted_dc_name, ps, depth))
00176                         return False;
00177         }
00178 
00179         if(!prs_align(ps))
00180                 return False;
00181 
00182         return True;
00183 }
00184 
00185 static BOOL net_io_ctrl_data_info_5(const char *desc, CTRL_DATA_INFO_5 *info, prs_struct *ps, int depth)
00186 {
00187         if (info == NULL)
00188                 return False;
00189                 
00190         prs_debug(ps, depth, desc, "net_io_ctrl_data_info_5");
00191         depth++;
00192         
00193         if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) )
00194                 return False;
00195         
00196         if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain))
00197                 return False;
00198                 
00199         if ( info->ptr_domain ) {
00200                 if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth))
00201                         return False;
00202         }
00203                 
00204         return True;
00205 }
00206 
00207 static BOOL net_io_ctrl_data_info_6(const char *desc, CTRL_DATA_INFO_6 *info, prs_struct *ps, int depth)
00208 {
00209         if (info == NULL)
00210                 return False;
00211                 
00212         prs_debug(ps, depth, desc, "net_io_ctrl_data_info_6");
00213         depth++;
00214         
00215         if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) )
00216                 return False;
00217         
00218         if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain))
00219                 return False;
00220                 
00221         if ( info->ptr_domain ) {
00222                 if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth))
00223                         return False;
00224         }
00225                 
00226         return True;
00227 }
00228 
00229 /*******************************************************************
00230  Reads or writes an NET_Q_LOGON_CTRL2 structure.
00231 ********************************************************************/
00232 
00233 BOOL net_io_q_logon_ctrl2(const char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth)
00234 {
00235         if (q_l == NULL)
00236                 return False;
00237 
00238         prs_debug(ps, depth, desc, "net_io_q_logon_ctrl2");
00239         depth++;
00240 
00241         if(!prs_align(ps))
00242                 return False;
00243 
00244         if(!prs_uint32("ptr          ", ps, depth, &q_l->ptr))
00245                 return False;
00246 
00247         if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
00248                 return False;
00249 
00250         if(!prs_align(ps))
00251                 return False;
00252 
00253         if(!prs_uint32("function_code", ps, depth, &q_l->function_code))
00254                 return False;
00255         if(!prs_uint32("query_level  ", ps, depth, &q_l->query_level))
00256                 return False;
00257         switch ( q_l->function_code ) {
00258                 case NETLOGON_CONTROL_REDISCOVER:
00259                         if ( !net_io_ctrl_data_info_5( "ctrl_data_info5", &q_l->info.info5, ps, depth) ) 
00260                                 return False;
00261                         break;
00262                         
00263                 case NETLOGON_CONTROL_TC_QUERY:
00264                         if ( !net_io_ctrl_data_info_6( "ctrl_data_info6", &q_l->info.info6, ps, depth) ) 
00265                                 return False;
00266                         break;
00267 
00268                 default:
00269                         DEBUG(0,("net_io_q_logon_ctrl2: unknown function_code [%d]\n",
00270                                 q_l->function_code));
00271                         return False;
00272         }
00273         
00274         return True;
00275 }
00276 
00277 /*******************************************************************
00278  Inits an NET_Q_LOGON_CTRL2 structure.
00279 ********************************************************************/
00280 
00281 void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, const char *srv_name,
00282                             uint32 query_level)
00283 {
00284         DEBUG(5,("init_q_logon_ctrl2\n"));
00285 
00286         q_l->function_code = 0x01;
00287         q_l->query_level = query_level;
00288 
00289         init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);
00290 }
00291 
00292 /*******************************************************************
00293  Inits an NET_R_LOGON_CTRL2 structure.
00294 ********************************************************************/
00295 
00296 void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level,
00297                             uint32 flags, uint32 pdc_status, 
00298                             uint32 logon_attempts, uint32 tc_status, 
00299                             const char *trusted_domain_name)
00300 {
00301         r_l->switch_value  = query_level; 
00302 
00303         switch (query_level) {
00304         case 1:
00305                 r_l->ptr = 1; /* undocumented pointer */
00306                 init_netinfo_1(&r_l->logon.info1, flags, pdc_status);   
00307                 r_l->status = NT_STATUS_OK;
00308                 break;
00309         case 2:
00310                 r_l->ptr = 1; /* undocumented pointer */
00311                 init_netinfo_2(&r_l->logon.info2, flags, pdc_status,
00312                                tc_status, trusted_domain_name); 
00313                 r_l->status = NT_STATUS_OK;
00314                 break;
00315         case 3:
00316                 r_l->ptr = 1; /* undocumented pointer */
00317                 init_netinfo_3(&r_l->logon.info3, flags, logon_attempts);       
00318                 r_l->status = NT_STATUS_OK;
00319                 break;
00320         default:
00321                 DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n",
00322                         r_l->switch_value));
00323                 r_l->ptr = 0; /* undocumented pointer */
00324 
00325                 /* take a guess at an error code... */
00326                 r_l->status = NT_STATUS_INVALID_INFO_CLASS;
00327                 break;
00328         }
00329 }
00330 
00331 /*******************************************************************
00332  Reads or writes an NET_R_LOGON_CTRL2 structure.
00333 ********************************************************************/
00334 
00335 BOOL net_io_r_logon_ctrl2(const char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth)
00336 {
00337         if (r_l == NULL)
00338                 return False;
00339 
00340         prs_debug(ps, depth, desc, "net_io_r_logon_ctrl2");
00341         depth++;
00342 
00343         if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value))
00344                 return False;
00345         if(!prs_uint32("ptr          ", ps, depth, &r_l->ptr))
00346                 return False;
00347 
00348         if (r_l->ptr != 0) {
00349                 switch (r_l->switch_value) {
00350                 case 1:
00351                         if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth))
00352                                 return False;
00353                         break;
00354                 case 2:
00355                         if(!net_io_netinfo_2("", &r_l->logon.info2, ps, depth))
00356                                 return False;
00357                         break;
00358                 case 3:
00359                         if(!net_io_netinfo_3("", &r_l->logon.info3, ps, depth))
00360                                 return False;
00361                         break;
00362                 default:
00363                         DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n",
00364                                 r_l->switch_value));
00365                         break;
00366                 }
00367         }
00368 
00369         if(!prs_ntstatus("status       ", ps, depth, &r_l->status))
00370                 return False;
00371 
00372         return True;
00373 }
00374 
00375 /*******************************************************************
00376  Reads or writes an NET_Q_LOGON_CTRL structure.
00377 ********************************************************************/
00378 
00379 BOOL net_io_q_logon_ctrl(const char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps, 
00380                          int depth)
00381 {
00382         prs_debug(ps, depth, desc, "net_io_q_logon_ctrl");
00383         depth++;
00384 
00385         if(!prs_align(ps))
00386                 return False;
00387 
00388         if(!prs_uint32("ptr          ", ps, depth, &q_l->ptr))
00389                 return False;
00390 
00391         if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
00392                 return False;
00393 
00394         if(!prs_align(ps))
00395                 return False;
00396 
00397         if(!prs_uint32("function_code", ps, depth, &q_l->function_code))
00398                 return False;
00399         if(!prs_uint32("query_level  ", ps, depth, &q_l->query_level))
00400                 return False;
00401 
00402         return True;
00403 }
00404 
00405 /*******************************************************************
00406  Inits an NET_Q_LOGON_CTRL structure.
00407 ********************************************************************/
00408 
00409 void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, const char *srv_name,
00410                            uint32 query_level)
00411 {
00412         DEBUG(5,("init_q_logon_ctrl\n"));
00413 
00414         q_l->function_code = 0x01; /* ??? */
00415         q_l->query_level = query_level;
00416 
00417         init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);
00418 }
00419 
00420 /*******************************************************************
00421  Inits an NET_R_LOGON_CTRL structure.
00422 ********************************************************************/
00423 
00424 void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level,
00425                            uint32 flags, uint32 pdc_status)
00426 {
00427         DEBUG(5,("init_r_logon_ctrl\n"));
00428 
00429         r_l->switch_value  = query_level; /* should only be 0x1 */
00430 
00431         switch (query_level) {
00432         case 1:
00433                 r_l->ptr = 1; /* undocumented pointer */
00434                 init_netinfo_1(&r_l->logon.info1, flags, pdc_status);   
00435                 r_l->status = NT_STATUS_OK;
00436                 break;
00437         default:
00438                 DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n",
00439                         r_l->switch_value));
00440                 r_l->ptr = 0; /* undocumented pointer */
00441 
00442                 /* take a guess at an error code... */
00443                 r_l->status = NT_STATUS_INVALID_INFO_CLASS;
00444                 break;
00445         }
00446 }
00447 
00448 /*******************************************************************
00449  Reads or writes an NET_R_LOGON_CTRL structure.
00450 ********************************************************************/
00451 
00452 BOOL net_io_r_logon_ctrl(const char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps, 
00453                          int depth)
00454 {
00455         prs_debug(ps, depth, desc, "net_io_r_logon_ctrl");
00456         depth++;
00457 
00458         if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value))
00459                 return False;
00460         if(!prs_uint32("ptr          ", ps, depth, &r_l->ptr))
00461                 return False;
00462 
00463         if (r_l->ptr != 0) {
00464                 switch (r_l->switch_value) {
00465                 case 1:
00466                         if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth))
00467                                 return False;
00468                         break;
00469                 default:
00470                         DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n",
00471                                 r_l->switch_value));
00472                         break;
00473                 }
00474         }
00475 
00476         if(!prs_ntstatus("status       ", ps, depth, &r_l->status))
00477                 return False;
00478 
00479         return True;
00480 }
00481 
00482 /*******************************************************************
00483  Inits an NET_R_GETANYDCNAME structure.
00484 ********************************************************************/
00485 void init_net_q_getanydcname(NET_Q_GETANYDCNAME *r_t, const char *logon_server,
00486                              const char *domainname)
00487 {
00488         DEBUG(5,("init_q_getanydcname\n"));
00489 
00490         r_t->ptr_logon_server = (logon_server != NULL);
00491         init_unistr2(&r_t->uni_logon_server, logon_server, UNI_STR_TERMINATE);
00492         r_t->ptr_domainname = (domainname != NULL);
00493         init_unistr2(&r_t->uni_domainname, domainname, UNI_STR_TERMINATE);
00494 }
00495 
00496 /*******************************************************************
00497  Reads or writes an NET_Q_GETANYDCNAME structure.
00498 ********************************************************************/
00499 
00500 BOOL net_io_q_getanydcname(const char *desc, NET_Q_GETANYDCNAME *r_t, prs_struct *ps,
00501                            int depth)
00502 {
00503         if (r_t == NULL)
00504                 return False;
00505 
00506         prs_debug(ps, depth, desc, "net_io_q_getanydcname");
00507         depth++;
00508 
00509         if (!prs_uint32("ptr_logon_server", ps, depth, &r_t->ptr_logon_server))
00510                 return False;
00511 
00512         if (!smb_io_unistr2("logon_server", &r_t->uni_logon_server,
00513                             r_t->ptr_logon_server, ps, depth))
00514                 return False;
00515 
00516         if (!prs_align(ps))
00517                 return False;
00518 
00519         if (!prs_uint32("ptr_domainname", ps, depth, &r_t->ptr_domainname))
00520                 return False;
00521 
00522         if (!smb_io_unistr2("domainname", &r_t->uni_domainname,
00523                             r_t->ptr_domainname, ps, depth))
00524                 return False;
00525 
00526         return True;
00527 }
00528 
00529 
00530 /*******************************************************************
00531  Inits an NET_R_GETANYDCNAME structure.
00532 ********************************************************************/
00533 void init_net_r_getanydcname(NET_R_GETANYDCNAME *r_t, const char *dcname)
00534 {
00535         DEBUG(5,("init_r_getanydcname\n"));
00536 
00537         init_unistr2(&r_t->uni_dcname, dcname, UNI_STR_TERMINATE);
00538 }
00539 
00540 /*******************************************************************
00541  Reads or writes an NET_R_GETANYDCNAME structure.
00542 ********************************************************************/
00543 
00544 BOOL net_io_r_getanydcname(const char *desc, NET_R_GETANYDCNAME *r_t, prs_struct *ps,
00545                            int depth)
00546 {
00547         if (r_t == NULL)
00548                 return False;
00549 
00550         prs_debug(ps, depth, desc, "net_io_r_getanydcname");
00551         depth++;
00552 
00553         if (!prs_uint32("ptr_dcname", ps, depth, &r_t->ptr_dcname))
00554                 return False;
00555 
00556         if (!smb_io_unistr2("dcname", &r_t->uni_dcname,
00557                             r_t->ptr_dcname, ps, depth))
00558                 return False;
00559 
00560         if (!prs_align(ps))
00561                 return False;
00562 
00563         if (!prs_werror("status", ps, depth, &r_t->status))
00564                 return False;
00565 
00566         return True;
00567 }
00568 
00569 /*******************************************************************
00570  Inits an NET_R_TRUST_DOM_LIST structure.
00571 ********************************************************************/
00572 
00573 void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
00574                         uint32 num_doms, const char *dom_name)
00575 {
00576         unsigned int i = 0;
00577 
00578         DEBUG(5,("init_r_trust_dom\n"));
00579 
00580         for (i = 0; i < MAX_TRUST_DOMS; i++) {
00581                 r_t->uni_trust_dom_name[i].uni_str_len = 0;
00582                 r_t->uni_trust_dom_name[i].uni_max_len = 0;
00583         }
00584         if (num_doms > MAX_TRUST_DOMS)
00585                 num_doms = MAX_TRUST_DOMS;
00586 
00587         for (i = 0; i < num_doms; i++) {
00588                 fstring domain_name;
00589                 fstrcpy(domain_name, dom_name);
00590                 strupper_m(domain_name);
00591                 init_unistr2(&r_t->uni_trust_dom_name[i], domain_name, UNI_STR_TERMINATE);
00592                 /* the use of UNISTR2 here is non-standard. */
00593                 r_t->uni_trust_dom_name[i].offset = 0x1;
00594         }
00595         
00596         r_t->status = NT_STATUS_OK;
00597 }
00598 
00599 /*******************************************************************
00600  Reads or writes an NET_R_TRUST_DOM_LIST structure.
00601 ********************************************************************/
00602 
00603 BOOL net_io_r_trust_dom(const char *desc, NET_R_TRUST_DOM_LIST *r_t, prs_struct *ps, int depth)
00604 {
00605         uint32 value;
00606 
00607         if (r_t == NULL)
00608                  return False;
00609 
00610         prs_debug(ps, depth, desc, "net_io_r_trust_dom");
00611         depth++;
00612 
00613         /* temporary code to give a valid response */
00614         value=2;
00615         if(!prs_uint32("status", ps, depth, &value))
00616                  return False;
00617 
00618         value=1;
00619         if(!prs_uint32("status", ps, depth, &value))
00620                  return False;
00621         value=2;
00622         if(!prs_uint32("status", ps, depth, &value))
00623                  return False;
00624 
00625         value=0;
00626         if(!prs_uint32("status", ps, depth, &value))
00627                  return False;
00628 
00629         value=0;
00630         if(!prs_uint32("status", ps, depth, &value))
00631                  return False;
00632 
00633 /* old non working code */
00634 #if 0
00635         int i;
00636 
00637         for (i = 0; i < MAX_TRUST_DOMS; i++) {
00638                 if (r_t->uni_trust_dom_name[i].uni_str_len == 0)
00639                         break;
00640                 if(!smb_io_unistr2("", &r_t->uni_trust_dom_name[i], True, ps, depth))
00641                          return False;
00642         }
00643 
00644         if(!prs_ntstatus("status", ps, depth, &r_t->status))
00645                  return False;
00646 #endif
00647         return True;
00648 }
00649 
00650 
00651 /*******************************************************************
00652  Reads or writes an NET_Q_TRUST_DOM_LIST structure.
00653 ********************************************************************/
00654 
00655 BOOL net_io_q_trust_dom(const char *desc, NET_Q_TRUST_DOM_LIST *q_l, prs_struct *ps, int depth)
00656 {
00657         if (q_l == NULL)
00658                  return False;
00659 
00660         prs_debug(ps, depth, desc, "net_io_q_trust_dom");
00661         depth++;
00662 
00663         if(!prs_uint32("ptr          ", ps, depth, &q_l->ptr))
00664                  return False;
00665         if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
00666                  return False;
00667 
00668         return True;
00669 }
00670 
00671 /*******************************************************************
00672  Inits an NET_Q_REQ_CHAL structure.
00673 ********************************************************************/
00674 
00675 void init_q_req_chal(NET_Q_REQ_CHAL *q_c,
00676                      const char *logon_srv, const char *logon_clnt,
00677                      const DOM_CHAL *clnt_chal)
00678 {
00679         DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
00680 
00681         q_c->undoc_buffer = 1; /* don't know what this buffer is */
00682 
00683         init_unistr2(&q_c->uni_logon_srv, logon_srv , UNI_STR_TERMINATE);
00684         init_unistr2(&q_c->uni_logon_clnt, logon_clnt, UNI_STR_TERMINATE);
00685 
00686         memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
00687 
00688         DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
00689 }
00690 
00691 /*******************************************************************
00692  Reads or writes an NET_Q_REQ_CHAL structure.
00693 ********************************************************************/
00694 
00695 BOOL net_io_q_req_chal(const char *desc,  NET_Q_REQ_CHAL *q_c, prs_struct *ps, int depth)
00696 {
00697         if (q_c == NULL)
00698                 return False;
00699 
00700         prs_debug(ps, depth, desc, "net_io_q_req_chal");
00701         depth++;
00702 
00703         if(!prs_align(ps))
00704                 return False;
00705     
00706         if(!prs_uint32("undoc_buffer", ps, depth, &q_c->undoc_buffer))
00707                 return False;
00708 
00709         if(!smb_io_unistr2("", &q_c->uni_logon_srv, True, ps, depth)) /* logon server unicode string */
00710                 return False;
00711         if(!smb_io_unistr2("", &q_c->uni_logon_clnt, True, ps, depth)) /* logon client unicode string */
00712                 return False;
00713 
00714         if(!smb_io_chal("", &q_c->clnt_chal, ps, depth))
00715                 return False;
00716 
00717         return True;
00718 }
00719 
00720 /*******************************************************************
00721  Reads or writes a structure.
00722 ********************************************************************/
00723 
00724 BOOL net_io_r_req_chal(const char *desc, NET_R_REQ_CHAL *r_c, prs_struct *ps, int depth)
00725 {
00726         if (r_c == NULL)
00727                 return False;
00728 
00729         prs_debug(ps, depth, desc, "net_io_r_req_chal");
00730         depth++;
00731 
00732         if(!prs_align(ps))
00733                 return False;
00734     
00735         if(!smb_io_chal("", &r_c->srv_chal, ps, depth)) /* server challenge */
00736                 return False;
00737 
00738         if(!prs_ntstatus("status", ps, depth, &r_c->status))
00739                 return False;
00740 
00741         return True;
00742 }
00743 
00744 
00745 /*******************************************************************
00746  Reads or writes a structure.
00747 ********************************************************************/
00748 
00749 BOOL net_io_q_auth(const char *desc, NET_Q_AUTH *q_a, prs_struct *ps, int depth)
00750 {
00751         if (q_a == NULL)
00752                 return False;
00753 
00754         prs_debug(ps, depth, desc, "net_io_q_auth");
00755         depth++;
00756 
00757         if(!prs_align(ps))
00758                 return False;
00759     
00760         if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
00761                 return False;
00762         if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
00763                 return False;
00764 
00765         return True;
00766 }
00767 
00768 /*******************************************************************
00769  Reads or writes a structure.
00770 ********************************************************************/
00771 
00772 BOOL net_io_r_auth(const char *desc, NET_R_AUTH *r_a, prs_struct *ps, int depth)
00773 {
00774         if (r_a == NULL)
00775                 return False;
00776 
00777         prs_debug(ps, depth, desc, "net_io_r_auth");
00778         depth++;
00779 
00780         if(!prs_align(ps))
00781                 return False;
00782     
00783         if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */
00784                 return False;
00785 
00786         if(!prs_ntstatus("status", ps, depth, &r_a->status))
00787                 return False;
00788 
00789         return True;
00790 }
00791 
00792 /*******************************************************************
00793  Inits a NET_Q_AUTH_2 struct.
00794 ********************************************************************/
00795 
00796 void init_q_auth_2(NET_Q_AUTH_2 *q_a,
00797                 const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name,
00798                 const DOM_CHAL *clnt_chal, uint32 clnt_flgs)
00799 {
00800         DEBUG(5,("init_q_auth_2: %d\n", __LINE__));
00801 
00802         init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name);
00803         memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
00804         q_a->clnt_flgs.neg_flags = clnt_flgs;
00805 
00806         DEBUG(5,("init_q_auth_2: %d\n", __LINE__));
00807 }
00808 
00809 /*******************************************************************
00810  Reads or writes a structure.
00811 ********************************************************************/
00812 
00813 BOOL net_io_q_auth_2(const char *desc, NET_Q_AUTH_2 *q_a, prs_struct *ps, int depth)
00814 {
00815         if (q_a == NULL)
00816                 return False;
00817 
00818         prs_debug(ps, depth, desc, "net_io_q_auth_2");
00819         depth++;
00820 
00821         if(!prs_align(ps))
00822                 return False;
00823     
00824         if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
00825                 return False;
00826         if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
00827                 return False;
00828         if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth))
00829                 return False;
00830 
00831         return True;
00832 }
00833 
00834 /*******************************************************************
00835  Reads or writes a structure.
00836 ********************************************************************/
00837 
00838 BOOL net_io_r_auth_2(const char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth)
00839 {
00840         if (r_a == NULL)
00841                 return False;
00842 
00843         prs_debug(ps, depth, desc, "net_io_r_auth_2");
00844         depth++;
00845 
00846         if(!prs_align(ps))
00847                 return False;
00848     
00849         if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */
00850                 return False;
00851         if(!net_io_neg_flags("", &r_a->srv_flgs, ps, depth))
00852                 return False;
00853 
00854         if(!prs_ntstatus("status", ps, depth, &r_a->status))
00855                 return False;
00856 
00857         return True;
00858 }
00859 
00860 /*******************************************************************
00861  Inits a NET_Q_AUTH_3 struct.
00862 ********************************************************************/
00863 
00864 void init_q_auth_3(NET_Q_AUTH_3 *q_a,
00865                 const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name,
00866                 const DOM_CHAL *clnt_chal, uint32 clnt_flgs)
00867 {
00868         DEBUG(5,("init_q_auth_3: %d\n", __LINE__));
00869 
00870         init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name);
00871         memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
00872         q_a->clnt_flgs.neg_flags = clnt_flgs;
00873 
00874         DEBUG(5,("init_q_auth_3: %d\n", __LINE__));
00875 }
00876 
00877 /*******************************************************************
00878  Reads or writes a structure.
00879 ********************************************************************/
00880 
00881 BOOL net_io_q_auth_3(const char *desc, NET_Q_AUTH_3 *q_a, prs_struct *ps, int depth)
00882 {
00883         if (q_a == NULL)
00884                 return False;
00885 
00886         prs_debug(ps, depth, desc, "net_io_q_auth_3");
00887         depth++;
00888 
00889         if(!prs_align(ps))
00890                 return False;
00891     
00892         if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */
00893                 return False;
00894         if(!smb_io_chal("", &q_a->clnt_chal, ps, depth))
00895                 return False;
00896         if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth))
00897                 return False;
00898 
00899         return True;
00900 }
00901 
00902 /*******************************************************************
00903  Reads or writes a structure.
00904 ********************************************************************/
00905 
00906 BOOL net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int depth)
00907 {
00908         if (r_a == NULL)
00909                 return False;
00910 
00911         prs_debug(ps, depth, desc, "net_io_r_auth_3");
00912         depth++;
00913 
00914         if(!prs_align(ps))
00915                 return False;
00916     
00917         if(!smb_io_chal("srv_chal", &r_a->srv_chal, ps, depth)) /* server challenge */
00918                 return False;
00919         if(!net_io_neg_flags("srv_flgs", &r_a->srv_flgs, ps, depth))
00920                 return False;
00921         if (!prs_uint32("unknown", ps, depth, &r_a->unknown))
00922                 return False;
00923 
00924         if(!prs_ntstatus("status", ps, depth, &r_a->status))
00925                 return False;
00926 
00927         return True;
00928 }
00929 
00930 
00931 /*******************************************************************
00932  Inits a NET_Q_SRV_PWSET.
00933 ********************************************************************/
00934 
00935 void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s,
00936                 const char *logon_srv, const char *sess_key, const char *acct_name, 
00937                 uint16 sec_chan, const char *comp_name,
00938                 DOM_CRED *cred, const uchar hashed_mach_pwd[16])
00939 {
00940         unsigned char nt_cypher[16];
00941         
00942         DEBUG(5,("init_q_srv_pwset\n"));
00943         
00944         /* Process the new password. */
00945         cred_hash3( nt_cypher, hashed_mach_pwd, (const unsigned char *)sess_key, 1);
00946 
00947         init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred);
00948 
00949         memcpy(q_s->pwd, nt_cypher, sizeof(q_s->pwd)); 
00950 }
00951 
00952 /*******************************************************************
00953  Reads or writes a structure.
00954 ********************************************************************/
00955 
00956 BOOL net_io_q_srv_pwset(const char *desc, NET_Q_SRV_PWSET *q_s, prs_struct *ps, int depth)
00957 {
00958         if (q_s == NULL)
00959                 return False;
00960 
00961         prs_debug(ps, depth, desc, "net_io_q_srv_pwset");
00962         depth++;
00963 
00964         if(!prs_align(ps))
00965                 return False;
00966     
00967         if(!smb_io_clnt_info("", &q_s->clnt_id, ps, depth)) /* client identification/authentication info */
00968                 return False;
00969         if(!prs_uint8s (False, "pwd", ps, depth, q_s->pwd, 16)) /* new password - undocumented */
00970                 return False;
00971 
00972         return True;
00973 }
00974 
00975 /*******************************************************************
00976  Reads or writes a structure.
00977 ********************************************************************/
00978 
00979 BOOL net_io_r_srv_pwset(const char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int depth)
00980 {
00981         if (r_s == NULL)
00982                 return False;
00983 
00984         prs_debug(ps, depth, desc, "net_io_r_srv_pwset");
00985         depth++;
00986 
00987         if(!prs_align(ps))
00988                 return False;
00989     
00990         if(!smb_io_cred("", &r_s->srv_cred, ps, depth)) /* server challenge */
00991                 return False;
00992 
00993         if(!prs_ntstatus("status", ps, depth, &r_s->status))
00994                 return False;
00995 
00996         return True;
00997 }
00998 
00999 /*******************************************************************
01000  Inits a NET_Q_SRV_PWSET2.
01001 ********************************************************************/
01002 
01003 void init_q_srv_pwset2(NET_Q_SRV_PWSET2 *q_s,
01004                        const char *logon_srv,
01005                        const char *sess_key,
01006                        const char *acct_name,
01007                        uint16 sec_chan,
01008                        const char *comp_name,
01009                        DOM_CRED *cred,
01010                        const char *clear_text_mach_pwd)
01011 {
01012         uint8_t password_buf[516];
01013         NET_CRYPT_PWD new_password;
01014 
01015         DEBUG(5,("init_q_srv_pwset2\n"));
01016 
01017         /* Process the new password. */
01018 
01019         encode_pw_buffer(password_buf, clear_text_mach_pwd, STR_UNICODE);
01020 
01021         SamOEMhash(password_buf, (const unsigned char *)sess_key, 516);
01022         memcpy(new_password.data, password_buf, 512);
01023         new_password.length = IVAL(password_buf, 512);
01024 
01025         init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred);
01026 
01027         memcpy(&q_s->pwd, &new_password, sizeof(q_s->pwd));
01028 }
01029 
01030 /*******************************************************************
01031  Reads or writes a structure.
01032 ********************************************************************/
01033 
01034 BOOL net_io_q_srv_pwset2(const char *desc, NET_Q_SRV_PWSET2 *q_s, prs_struct *ps, int depth)
01035 {
01036         if (q_s == NULL)
01037                 return False;
01038 
01039         prs_debug(ps, depth, desc, "net_io_q_srv_pwset2");
01040         depth++;
01041 
01042         if(!prs_align(ps))
01043                 return False;
01044 
01045         if(!smb_io_clnt_info("", &q_s->clnt_id, ps, depth)) /* client identification/authentication info */
01046                 return False;
01047         if(!prs_uint8s(False, "pwd.data", ps, depth, q_s->pwd.data, 512)) /* new password - undocumented */
01048                 return False;
01049         if(!prs_uint32("pwd.length", ps, depth, &q_s->pwd.length)) /* new password - undocumented */
01050                 return False;
01051 
01052         return True;
01053 }
01054 
01055 /*******************************************************************
01056  Reads or writes a structure.
01057 ********************************************************************/
01058 
01059 BOOL net_io_r_srv_pwset2(const char *desc, NET_R_SRV_PWSET2 *r_s, prs_struct *ps, int depth)
01060 {
01061         if (r_s == NULL)
01062                 return False;
01063 
01064         prs_debug(ps, depth, desc, "net_io_r_srv_pwset2");
01065         depth++;
01066 
01067         if(!prs_align(ps))
01068                 return False;
01069 
01070         if(!smb_io_cred("", &r_s->srv_cred, ps, depth)) /* server challenge */
01071                 return False;
01072 
01073         if(!prs_ntstatus("status", ps, depth, &r_s->status))
01074                 return False;
01075 
01076         return True;
01077 }
01078 
01079 /*************************************************************************
01080  Init DOM_SID2 array from a string containing multiple sids
01081  *************************************************************************/
01082 
01083 static int init_dom_sid2s(TALLOC_CTX *ctx, const char *sids_str, DOM_SID2 **ppsids)
01084 {
01085         const char *ptr;
01086         pstring s2;
01087         int count = 0;
01088 
01089         DEBUG(4,("init_dom_sid2s: %s\n", sids_str ? sids_str:""));
01090 
01091         *ppsids = NULL;
01092 
01093         if(sids_str) {
01094                 int number;
01095                 DOM_SID2 *sids;
01096 
01097                 /* Count the number of valid SIDs. */
01098                 for (count = 0, ptr = sids_str; next_token(&ptr, s2, NULL, sizeof(s2)); ) {
01099                         DOM_SID tmpsid;
01100                         if (string_to_sid(&tmpsid, s2))
01101                                 count++;
01102                 }
01103 
01104                 /* Now allocate space for them. */
01105                 if (count) {
01106                         *ppsids = TALLOC_ZERO_ARRAY(ctx, DOM_SID2, count);
01107                         if (*ppsids == NULL)
01108                                 return 0;
01109                 } else {
01110                         *ppsids = NULL;
01111                 }
01112 
01113                 sids = *ppsids;
01114 
01115                 for (number = 0, ptr = sids_str; next_token(&ptr, s2, NULL, sizeof(s2)); ) {
01116                         DOM_SID tmpsid;
01117                         if (string_to_sid(&tmpsid, s2)) {
01118                                 /* count only valid sids */
01119                                 init_dom_sid2(&sids[number], &tmpsid);
01120                                 number++;
01121                         }
01122                 }
01123         }
01124 
01125         return count;
01126 }
01127 
01128 /*******************************************************************
01129  Inits a NET_ID_INFO_1 structure.
01130 ********************************************************************/
01131 
01132 void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name,
01133                                 uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
01134                                 const char *user_name, const char *wksta_name,
01135                                 const char *sess_key,
01136                                 unsigned char lm_cypher[16], unsigned char nt_cypher[16])
01137 {
01138         unsigned char lm_owf[16];
01139         unsigned char nt_owf[16];
01140 
01141         DEBUG(5,("init_id_info1: %d\n", __LINE__));
01142 
01143         id->ptr_id_info1 = 1;
01144 
01145         id->param_ctrl = param_ctrl;
01146         init_logon_id(&id->logon_id, log_id_low, log_id_high);
01147 
01148 
01149         if (lm_cypher && nt_cypher) {
01150                 unsigned char key[16];
01151 #ifdef DEBUG_PASSWORD
01152                 DEBUG(100,("lm cypher:"));
01153                 dump_data(100, (char *)lm_cypher, 16);
01154 
01155                 DEBUG(100,("nt cypher:"));
01156                 dump_data(100, (char *)nt_cypher, 16);
01157 #endif
01158 
01159                 memset(key, 0, 16);
01160                 memcpy(key, sess_key, 8);
01161 
01162                 memcpy(lm_owf, lm_cypher, 16);
01163                 SamOEMhash(lm_owf, key, 16);
01164                 memcpy(nt_owf, nt_cypher, 16);
01165                 SamOEMhash(nt_owf, key, 16);
01166 
01167 #ifdef DEBUG_PASSWORD
01168                 DEBUG(100,("encrypt of lm owf password:"));
01169                 dump_data(100, (char *)lm_owf, 16);
01170 
01171                 DEBUG(100,("encrypt of nt owf password:"));
01172                 dump_data(100, (char *)nt_owf, 16);
01173 #endif
01174                 /* set up pointers to cypher blocks */
01175                 lm_cypher = lm_owf;
01176                 nt_cypher = nt_owf;
01177         }
01178 
01179         init_owf_info(&id->lm_owf, lm_cypher);
01180         init_owf_info(&id->nt_owf, nt_cypher);
01181 
01182         init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
01183         init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
01184         init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
01185         init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
01186         init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
01187         init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
01188 }
01189 
01190 /*******************************************************************
01191  Reads or writes an NET_ID_INFO_1 structure.
01192 ********************************************************************/
01193 
01194 static BOOL net_io_id_info1(const char *desc,  NET_ID_INFO_1 *id, prs_struct *ps, int depth)
01195 {
01196         if (id == NULL)
01197                 return False;
01198 
01199         prs_debug(ps, depth, desc, "net_io_id_info1");
01200         depth++;
01201 
01202         if(!prs_align(ps))
01203                 return False;
01204         
01205         if(!prs_uint32("ptr_id_info1", ps, depth, &id->ptr_id_info1))
01206                 return False;
01207 
01208         if (id->ptr_id_info1 != 0) {
01209                 if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth))
01210                         return False;
01211 
01212                 if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl))
01213                         return False;
01214                 if(!smb_io_logon_id("", &id->logon_id, ps, depth))
01215                         return False;
01216 
01217                 if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth))
01218                         return False;
01219                 if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth))
01220                         return False;
01221 
01222                 if(!smb_io_owf_info("", &id->lm_owf, ps, depth))
01223                         return False;
01224                 if(!smb_io_owf_info("", &id->nt_owf, ps, depth))
01225                         return False;
01226 
01227                 if(!smb_io_unistr2("unistr2", &id->uni_domain_name,
01228                                 id->hdr_domain_name.buffer, ps, depth))
01229                         return False;
01230                 if(!smb_io_unistr2("unistr2", &id->uni_user_name,
01231                                 id->hdr_user_name.buffer, ps, depth))
01232                         return False;
01233                 if(!smb_io_unistr2("unistr2", &id->uni_wksta_name,
01234                                 id->hdr_wksta_name.buffer, ps, depth))
01235                         return False;
01236         }
01237 
01238         return True;
01239 }
01240 
01241 /*******************************************************************
01242 Inits a NET_ID_INFO_2 structure.
01243 
01244 This is a network logon packet. The log_id parameters
01245 are what an NT server would generate for LUID once the
01246 user is logged on. I don't think we care about them.
01247 
01248 Note that this has no access to the NT and LM hashed passwords,
01249 so it forwards the challenge, and the NT and LM responses (24
01250 bytes each) over the secure channel to the Domain controller
01251 for it to say yea or nay. This is the preferred method of 
01252 checking for a logon as it doesn't export the password
01253 hashes to anyone who has compromised the secure channel. JRA.
01254 ********************************************************************/
01255 
01256 void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name,
01257                    uint32 param_ctrl,
01258                    uint32 log_id_low, uint32 log_id_high,
01259                    const char *user_name, const char *wksta_name,
01260                    const uchar lm_challenge[8],
01261                    const uchar * lm_chal_resp, size_t lm_chal_resp_len,
01262                    const uchar * nt_chal_resp, size_t nt_chal_resp_len)
01263 {
01264 
01265         DEBUG(5,("init_id_info2: %d\n", __LINE__));
01266 
01267         id->ptr_id_info2 = 1;
01268 
01269         id->param_ctrl = param_ctrl;
01270         init_logon_id(&id->logon_id, log_id_low, log_id_high);
01271 
01272         memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal));
01273         init_str_hdr(&id->hdr_nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0);
01274         init_str_hdr(&id->hdr_lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0);
01275 
01276         init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
01277         init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
01278         init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
01279         init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
01280         init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
01281         init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
01282 
01283         init_string2(&id->nt_chal_resp, (const char *)nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len);
01284         init_string2(&id->lm_chal_resp, (const char *)lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len);
01285 
01286 }
01287 
01288 /*******************************************************************
01289  Reads or writes an NET_ID_INFO_2 structure.
01290 ********************************************************************/
01291 
01292 static BOOL net_io_id_info2(const char *desc,  NET_ID_INFO_2 *id, prs_struct *ps, int depth)
01293 {
01294         if (id == NULL)
01295                 return False;
01296 
01297         prs_debug(ps, depth, desc, "net_io_id_info2");
01298         depth++;
01299 
01300         if(!prs_align(ps))
01301                 return False;
01302         
01303         if(!prs_uint32("ptr_id_info2", ps, depth, &id->ptr_id_info2))
01304                 return False;
01305 
01306         if (id->ptr_id_info2 != 0) {
01307                 if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth))
01308                         return False;
01309 
01310                 if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl))
01311                         return False;
01312                 if(!smb_io_logon_id("", &id->logon_id, ps, depth))
01313                         return False;
01314 
01315                 if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth))
01316                         return False;
01317                 if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth))
01318                         return False;
01319 
01320                 if(!prs_uint8s (False, "lm_chal", ps, depth, id->lm_chal, 8)) /* lm 8 byte challenge */
01321                         return False;
01322 
01323                 if(!smb_io_strhdr("hdr_nt_chal_resp", &id->hdr_nt_chal_resp, ps, depth))
01324                         return False;
01325                 if(!smb_io_strhdr("hdr_lm_chal_resp", &id->hdr_lm_chal_resp, ps, depth))
01326                         return False;
01327 
01328                 if(!smb_io_unistr2("uni_domain_name", &id->uni_domain_name,
01329                                 id->hdr_domain_name.buffer, ps, depth))
01330                         return False;
01331                 if(!smb_io_unistr2("uni_user_name  ", &id->uni_user_name,
01332                                 id->hdr_user_name.buffer, ps, depth))
01333                         return False;
01334                 if(!smb_io_unistr2("uni_wksta_name ", &id->uni_wksta_name,
01335                                 id->hdr_wksta_name.buffer, ps, depth))
01336                         return False;
01337                 if(!smb_io_string2("nt_chal_resp", &id->nt_chal_resp,
01338                                 id->hdr_nt_chal_resp.buffer, ps, depth))
01339                         return False;
01340                 if(!smb_io_string2("lm_chal_resp", &id->lm_chal_resp,
01341                                 id->hdr_lm_chal_resp.buffer, ps, depth))
01342                         return False;
01343         }
01344 
01345         return True;
01346 }
01347 
01348 
01349 /*******************************************************************
01350  Inits a DOM_SAM_INFO structure.
01351 ********************************************************************/
01352 
01353 void init_sam_info(DOM_SAM_INFO *sam,
01354                                 const char *logon_srv, const char *comp_name,
01355                                 DOM_CRED *clnt_cred,
01356                                 DOM_CRED *rtn_cred, uint16 logon_level,
01357                                 NET_ID_INFO_CTR *ctr)
01358 {
01359         DEBUG(5,("init_sam_info: %d\n", __LINE__));
01360 
01361         init_clnt_info2(&sam->client, logon_srv, comp_name, clnt_cred);
01362 
01363         if (rtn_cred != NULL) {
01364                 sam->ptr_rtn_cred = 1;
01365                 memcpy(&sam->rtn_cred, rtn_cred, sizeof(sam->rtn_cred));
01366         } else {
01367                 sam->ptr_rtn_cred = 0;
01368         }
01369 
01370         sam->logon_level  = logon_level;
01371         sam->ctr          = ctr;
01372 }
01373 
01374 /*******************************************************************
01375  Reads or writes a DOM_SAM_INFO structure.
01376 ********************************************************************/
01377 
01378 static BOOL net_io_id_info_ctr(const char *desc, NET_ID_INFO_CTR **pp_ctr, prs_struct *ps, int depth)
01379 {
01380         NET_ID_INFO_CTR *ctr = *pp_ctr;
01381 
01382         prs_debug(ps, depth, desc, "smb_io_sam_info_ctr");
01383         depth++;
01384 
01385         if (UNMARSHALLING(ps)) {
01386                 ctr = *pp_ctr = PRS_ALLOC_MEM(ps, NET_ID_INFO_CTR, 1);
01387                 if (ctr == NULL)
01388                         return False;
01389         }
01390         
01391         if (ctr == NULL)
01392                 return False;
01393 
01394         /* don't 4-byte align here! */
01395 
01396         if(!prs_uint16("switch_value ", ps, depth, &ctr->switch_value))
01397                 return False;
01398 
01399         switch (ctr->switch_value) {
01400         case 1:
01401                 if(!net_io_id_info1("", &ctr->auth.id1, ps, depth))
01402                         return False;
01403                 break;
01404         case 2:
01405                 if(!net_io_id_info2("", &ctr->auth.id2, ps, depth))
01406                         return False;
01407                 break;
01408         default:
01409                 /* PANIC! */
01410                 DEBUG(4,("smb_io_sam_info_ctr: unknown switch_value!\n"));
01411                 break;
01412         }
01413 
01414         return True;
01415 }
01416 
01417 /*******************************************************************
01418  Reads or writes a DOM_SAM_INFO structure.
01419  ********************************************************************/
01420 
01421 static BOOL smb_io_sam_info(const char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int depth)
01422 {
01423         if (sam == NULL)
01424                 return False;
01425 
01426         prs_debug(ps, depth, desc, "smb_io_sam_info");
01427         depth++;
01428 
01429         if(!prs_align(ps))
01430                 return False;
01431         
01432         if(!smb_io_clnt_info2("", &sam->client, ps, depth))
01433                 return False;
01434 
01435         if(!prs_uint32("ptr_rtn_cred ", ps, depth, &sam->ptr_rtn_cred))
01436                 return False;
01437         if (sam->ptr_rtn_cred) {
01438                 if(!smb_io_cred("", &sam->rtn_cred, ps, depth))
01439                         return False;
01440         }
01441 
01442         if(!prs_uint16("logon_level  ", ps, depth, &sam->logon_level))
01443                 return False;
01444 
01445         if (sam->logon_level != 0) {
01446                 if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth))
01447                         return False;
01448         }
01449 
01450         return True;
01451 }
01452 
01453 /*******************************************************************
01454  Reads or writes a DOM_SAM_INFO_EX structure.
01455  ********************************************************************/
01456 
01457 static BOOL smb_io_sam_info_ex(const char *desc, DOM_SAM_INFO_EX *sam, prs_struct *ps, int depth)
01458 {
01459         if (sam == NULL)
01460                 return False;
01461 
01462         prs_debug(ps, depth, desc, "smb_io_sam_info_ex");
01463         depth++;
01464 
01465         if(!prs_align(ps))
01466                 return False;
01467         
01468         if(!smb_io_clnt_srv("", &sam->client, ps, depth))
01469                 return False;
01470 
01471         if(!prs_uint16("logon_level  ", ps, depth, &sam->logon_level))
01472                 return False;
01473 
01474         if (sam->logon_level != 0) {
01475                 if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth))
01476                         return False;
01477         }
01478 
01479         return True;
01480 }
01481 
01482 /*************************************************************************
01483  Inits a NET_USER_INFO_3 structure.
01484 
01485  This is a network logon reply packet, and contains much information about
01486  the user.  This information is passed as a (very long) paramater list
01487  to avoid having to link in the PASSDB code to every program that deals 
01488  with this file.
01489  *************************************************************************/
01490 
01491 void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr, 
01492                          uint32                user_rid,
01493                          uint32                group_rid,
01494 
01495                          const char*            user_name,
01496                          const char*            full_name,
01497                          const char*            home_dir,
01498                          const char*            dir_drive,
01499                          const char*            logon_script,
01500                          const char*            profile_path,
01501 
01502                          time_t unix_logon_time,
01503                          time_t unix_logoff_time,
01504                          time_t unix_kickoff_time,
01505                          time_t unix_pass_last_set_time,
01506                          time_t unix_pass_can_change_time,
01507                          time_t unix_pass_must_change_time,
01508                          
01509                          uint16 logon_count, uint16 bad_pw_count,
01510                          uint32 num_groups, const DOM_GID *gids,
01511                          uint32 user_flgs, uint32 acct_flags,
01512                          uchar user_session_key[16],
01513                          uchar lm_session_key[8],
01514                          const char *logon_srv, const char *logon_dom,
01515                          const DOM_SID *dom_sid)
01516 {
01517         /* only cope with one "other" sid, right now. */
01518         /* need to count the number of space-delimited sids */
01519         unsigned int i;
01520         int num_other_sids = 0;
01521         
01522         NTTIME          logon_time, logoff_time, kickoff_time,
01523                         pass_last_set_time, pass_can_change_time,
01524                         pass_must_change_time;
01525 
01526         ZERO_STRUCTP(usr);
01527 
01528         usr->ptr_user_info = 1; /* yes, we're bothering to put USER_INFO data here */
01529 
01530         /* Create NTTIME structs */
01531         unix_to_nt_time (&logon_time,            unix_logon_time);
01532         unix_to_nt_time (&logoff_time,           unix_logoff_time);
01533         unix_to_nt_time (&kickoff_time,          unix_kickoff_time);
01534         unix_to_nt_time (&pass_last_set_time,    unix_pass_last_set_time);
01535         unix_to_nt_time (&pass_can_change_time,  unix_pass_can_change_time);
01536         unix_to_nt_time (&pass_must_change_time, unix_pass_must_change_time);
01537 
01538         usr->logon_time            = logon_time;
01539         usr->logoff_time           = logoff_time;
01540         usr->kickoff_time          = kickoff_time;
01541         usr->pass_last_set_time    = pass_last_set_time;
01542         usr->pass_can_change_time  = pass_can_change_time;
01543         usr->pass_must_change_time = pass_must_change_time;
01544 
01545         usr->logon_count = logon_count;
01546         usr->bad_pw_count = bad_pw_count;
01547 
01548         usr->user_rid = user_rid;
01549         usr->group_rid = group_rid;
01550         usr->num_groups = num_groups;
01551 
01552         usr->buffer_groups = 1; /* indicates fill in groups, below, even if there are none */
01553         usr->user_flgs = user_flgs;
01554         usr->acct_flags = acct_flags;
01555 
01556         if (user_session_key != NULL)
01557                 memcpy(usr->user_sess_key, user_session_key, sizeof(usr->user_sess_key));
01558         else
01559                 memset((char *)usr->user_sess_key, '\0', sizeof(usr->user_sess_key));
01560 
01561         usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */
01562 
01563         memset((char *)usr->lm_sess_key, '\0', sizeof(usr->lm_sess_key));
01564 
01565         for (i=0; i<7; i++) {
01566                 memset(&usr->unknown[i], '\0', sizeof(usr->unknown));
01567         }
01568 
01569         if (lm_session_key != NULL) {
01570                 memcpy(usr->lm_sess_key, lm_session_key, sizeof(usr->lm_sess_key));
01571         }
01572 
01573         num_other_sids = init_dom_sid2s(ctx, NULL, &usr->other_sids);
01574 
01575         usr->num_other_sids = num_other_sids;
01576         usr->buffer_other_sids = (num_other_sids != 0) ? 1 : 0; 
01577         
01578         init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
01579         init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
01580         init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
01581         init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
01582         init_unistr2(&usr->uni_logon_script, logon_script, UNI_FLAGS_NONE);
01583         init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
01584         init_unistr2(&usr->uni_profile_path, profile_path, UNI_FLAGS_NONE);
01585         init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
01586         init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
01587         init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
01588         init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
01589         init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
01590 
01591         usr->num_groups2 = num_groups;
01592 
01593         if (num_groups) {
01594                 usr->gids = TALLOC_ZERO_ARRAY(ctx,DOM_GID,num_groups);
01595                 if (usr->gids == NULL)
01596                         return;
01597         } else {
01598                 usr->gids = NULL;
01599         }
01600 
01601         for (i = 0; i < num_groups; i++) 
01602                 usr->gids[i] = gids[i]; 
01603                 
01604         init_unistr2(&usr->uni_logon_srv, logon_srv, UNI_FLAGS_NONE);
01605         init_uni_hdr(&usr->hdr_logon_srv, &usr->uni_logon_srv);
01606         init_unistr2(&usr->uni_logon_dom, logon_dom, UNI_FLAGS_NONE);
01607         init_uni_hdr(&usr->hdr_logon_dom, &usr->uni_logon_dom);
01608 
01609         init_dom_sid2(&usr->dom_sid, dom_sid);
01610         /* "other" sids are set up above */
01611 }
01612 
01613 static void dump_acct_flags(uint32 acct_flags) {
01614 
01615         int lvl = 10;
01616         DEBUG(lvl,("dump_acct_flags\n"));
01617         if (acct_flags & ACB_NORMAL) {
01618                 DEBUGADD(lvl,("\taccount has ACB_NORMAL\n"));
01619         }
01620         if (acct_flags & ACB_PWNOEXP) {
01621                 DEBUGADD(lvl,("\taccount has ACB_PWNOEXP\n"));
01622         }
01623         if (acct_flags & ACB_ENC_TXT_PWD_ALLOWED) {
01624                 DEBUGADD(lvl,("\taccount has ACB_ENC_TXT_PWD_ALLOWED\n"));
01625         }
01626         if (acct_flags & ACB_NOT_DELEGATED) {
01627                 DEBUGADD(lvl,("\taccount has ACB_NOT_DELEGATED\n"));
01628         }
01629         if (acct_flags & ACB_USE_DES_KEY_ONLY) {
01630                 DEBUGADD(lvl,("\taccount has ACB_USE_DES_KEY_ONLY set, sig verify wont work\n"));
01631         }
01632         if (acct_flags & ACB_NO_AUTH_DATA_REQD) {
01633                 DEBUGADD(lvl,("\taccount has ACB_NO_AUTH_DATA_REQD set\n"));
01634         }
01635         if (acct_flags & ACB_PWEXPIRED) {
01636                 DEBUGADD(lvl,("\taccount has ACB_PWEXPIRED set\n"));
01637         }
01638 }
01639 
01640 static void dump_user_flgs(uint32 user_flags) {
01641 
01642         int lvl = 10;
01643         DEBUG(lvl,("dump_user_flgs\n"));
01644         if (user_flags & LOGON_EXTRA_SIDS) {
01645                 DEBUGADD(lvl,("\taccount has LOGON_EXTRA_SIDS\n"));
01646         }
01647         if (user_flags & LOGON_RESOURCE_GROUPS) {
01648                 DEBUGADD(lvl,("\taccount has LOGON_RESOURCE_GROUPS\n"));
01649         }
01650         if (user_flags & LOGON_NTLMV2_ENABLED) {
01651                 DEBUGADD(lvl,("\taccount has LOGON_NTLMV2_ENABLED\n"));
01652         }
01653         if (user_flags & LOGON_CACHED_ACCOUNT) {
01654                 DEBUGADD(lvl,("\taccount has LOGON_CACHED_ACCOUNT\n"));
01655         }
01656         if (user_flags & LOGON_PROFILE_PATH_RETURNED) {
01657                 DEBUGADD(lvl,("\taccount has LOGON_PROFILE_PATH_RETURNED\n"));
01658         }
01659         if (user_flags & LOGON_SERVER_TRUST_ACCOUNT) {
01660                 DEBUGADD(lvl,("\taccount has LOGON_SERVER_TRUST_ACCOUNT\n"));
01661         }
01662 
01663 
01664 }
01665 
01666 /*******************************************************************
01667  This code has been modified to cope with a NET_USER_INFO_2 - which is
01668  exactly the same as a NET_USER_INFO_3, minus the other sids parameters.
01669  We use validation level to determine if we're marshalling a info 2 or
01670  INFO_3 - be we always return an INFO_3. Based on code donated by Marc
01671  Jacobsen at HP. JRA.
01672 ********************************************************************/
01673 
01674 BOOL net_io_user_info3(const char *desc, NET_USER_INFO_3 *usr, prs_struct *ps, 
01675                        int depth, uint16 validation_level, BOOL kerb_validation_level)
01676 {
01677         unsigned int i;
01678 
01679         if (usr == NULL)
01680                 return False;
01681 
01682         prs_debug(ps, depth, desc, "net_io_user_info3");
01683         depth++;
01684 
01685         if (UNMARSHALLING(ps))
01686                 ZERO_STRUCTP(usr);
01687 
01688         if(!prs_align(ps))
01689                 return False;
01690         
01691         if(!prs_uint32("ptr_user_info ", ps, depth, &usr->ptr_user_info))
01692                 return False;
01693 
01694         if (usr->ptr_user_info == 0)
01695                 return True;
01696 
01697         if(!smb_io_time("logon time", &usr->logon_time, ps, depth)) /* logon time */
01698                 return False;
01699         if(!smb_io_time("logoff time", &usr->logoff_time, ps, depth)) /* logoff time */
01700                 return False;
01701         if(!smb_io_time("kickoff time", &usr->kickoff_time, ps, depth)) /* kickoff time */
01702                 return False;
01703         if(!smb_io_time("last set time", &usr->pass_last_set_time, ps, depth)) /* password last set time */
01704                 return False;
01705         if(!smb_io_time("can change time", &usr->pass_can_change_time , ps, depth)) /* password can change time */
01706                 return False;
01707         if(!smb_io_time("must change time", &usr->pass_must_change_time, ps, depth)) /* password must change time */
01708                 return False;
01709 
01710         if(!smb_io_unihdr("hdr_user_name", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
01711                 return False;
01712         if(!smb_io_unihdr("hdr_full_name", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
01713                 return False;
01714         if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
01715                 return False;
01716         if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
01717                 return False;
01718         if(!smb_io_unihdr("hdr_home_dir", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
01719                 return False;
01720         if(!smb_io_unihdr("hdr_dir_drive", &usr->hdr_dir_drive, ps, depth)) /* home directory drive unicode string header */
01721                 return False;
01722 
01723         if(!prs_uint16("logon_count   ", ps, depth, &usr->logon_count))  /* logon count */
01724                 return False;
01725         if(!prs_uint16("bad_pw_count  ", ps, depth, &usr->bad_pw_count)) /* bad password count */
01726                 return False;
01727 
01728         if(!prs_uint32("user_rid      ", ps, depth, &usr->user_rid))       /* User RID */
01729                 return False;
01730         if(!prs_uint32("group_rid     ", ps, depth, &usr->group_rid))      /* Group RID */
01731                 return False;
01732         if(!prs_uint32("num_groups    ", ps, depth, &usr->num_groups))    /* num groups */
01733                 return False;
01734         if(!prs_uint32("buffer_groups ", ps, depth, &usr->buffer_groups)) /* undocumented buffer pointer to groups. */
01735                 return False;
01736         if(!prs_uint32("user_flgs     ", ps, depth, &usr->user_flgs))     /* user flags */
01737                 return False;
01738         dump_user_flgs(usr->user_flgs);
01739         if(!prs_uint8s(False, "user_sess_key", ps, depth, usr->user_sess_key, 16)) /* user session key */
01740                 return False;
01741 
01742         if(!smb_io_unihdr("hdr_logon_srv", &usr->hdr_logon_srv, ps, depth)) /* logon server unicode string header */
01743                 return False;
01744         if(!smb_io_unihdr("hdr_logon_dom", &usr->hdr_logon_dom, ps, depth)) /* logon domain unicode string header */
01745                 return False;
01746 
01747         if(!prs_uint32("buffer_dom_id ", ps, depth, &usr->buffer_dom_id)) /* undocumented logon domain id pointer */
01748                 return False;
01749 
01750         if(!prs_uint8s(False, "lm_sess_key", ps, depth, usr->lm_sess_key, 8)) /* lm session key */
01751                 return False;
01752 
01753         if(!prs_uint32("acct_flags ", ps, depth, &usr->acct_flags)) /* Account flags  */
01754                 return False;
01755         dump_acct_flags(usr->acct_flags);
01756         for (i = 0; i < 7; i++)
01757         {
01758                 if (!prs_uint32("unkown", ps, depth, &usr->unknown[i])) /* unknown */
01759                         return False;
01760         }
01761 
01762         if (validation_level == 3) {
01763                 if(!prs_uint32("num_other_sids", ps, depth, &usr->num_other_sids)) /* 0 - num_sids */
01764                         return False;
01765                 if(!prs_uint32("buffer_other_sids", ps, depth, &usr->buffer_other_sids)) /* NULL - undocumented pointer to SIDs. */
01766                         return False;
01767         } else {
01768                 if (UNMARSHALLING(ps)) {
01769                         usr->num_other_sids = 0;
01770                         usr->buffer_other_sids = 0;
01771                 }
01772         }
01773                 
01774         /* get kerb validation info (not really part of user_info_3) - Guenther */
01775 
01776         if (kerb_validation_level) {
01777 
01778                 if(!prs_uint32("ptr_res_group_dom_sid", ps, depth, &usr->ptr_res_group_dom_sid))
01779                         return False;
01780                 if(!prs_uint32("res_group_count", ps, depth, &usr->res_group_count))
01781                         return False;
01782                 if(!prs_uint32("ptr_res_groups", ps, depth, &usr->ptr_res_groups))
01783                         return False;
01784         }
01785 
01786         if(!smb_io_unistr2("uni_user_name", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
01787                 return False;
01788         if(!smb_io_unistr2("uni_full_name", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
01789                 return False;
01790         if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
01791                 return False;
01792         if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
01793                 return False;
01794         if(!smb_io_unistr2("uni_home_dir", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
01795                 return False;
01796         if(!smb_io_unistr2("uni_dir_drive", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
01797                 return False;
01798 
01799         if(!prs_align(ps))
01800                 return False;
01801 
01802         if(!prs_uint32("num_groups2   ", ps, depth, &usr->num_groups2))        /* num groups2 */
01803                 return False;
01804 
01805         if (usr->num_groups != usr->num_groups2) {
01806                 DEBUG(3,("net_io_user_info3: num_groups mismatch! (%d != %d)\n", 
01807                          usr->num_groups, usr->num_groups2));
01808                 return False;
01809         }
01810 
01811         if (UNMARSHALLING(ps)) {
01812                 if (usr->num_groups) {
01813                         usr->gids = PRS_ALLOC_MEM(ps, DOM_GID, usr->num_groups);
01814                         if (usr->gids == NULL)
01815                                 return False;
01816                 } else {
01817                         usr->gids = NULL;
01818                 }
01819         }
01820 
01821         for (i = 0; i < usr->num_groups; i++) {
01822                 if(!smb_io_gid("", &usr->gids[i], ps, depth)) /* group info */
01823                         return False;
01824         }
01825 
01826         if(!smb_io_unistr2("uni_logon_srv", &usr->uni_logon_srv, usr->hdr_logon_srv.buffer, ps, depth)) /* logon server unicode string */
01827                 return False;
01828         if(!smb_io_unistr2("uni_logon_dom", &usr->uni_logon_dom, usr->hdr_logon_dom.buffer, ps, depth)) /* logon domain unicode string */
01829                 return False;
01830 
01831         if(!smb_io_dom_sid2("", &usr->dom_sid, ps, depth))           /* domain SID */
01832                 return False;
01833 
01834         if (validation_level == 3 && usr->buffer_other_sids) {
01835 
01836                 uint32 num_other_sids = usr->num_other_sids;
01837 
01838                 if (!(usr->user_flgs & LOGON_EXTRA_SIDS)) {
01839                         DEBUG(10,("net_io_user_info3: user_flgs attribute does not have LOGON_EXTRA_SIDS\n"));
01840                         /* return False; */
01841                 }
01842 
01843                 if (!prs_uint32("num_other_sids", ps, depth,
01844                                 &num_other_sids))
01845                         return False;
01846 
01847                 if (num_other_sids != usr->num_other_sids)
01848                         return False;
01849 
01850                 if (UNMARSHALLING(ps)) {
01851                         if (usr->num_other_sids) {
01852                                 usr->other_sids = PRS_ALLOC_MEM(ps, DOM_SID2, usr->num_other_sids);
01853                                 usr->other_sids_attrib =
01854                                         PRS_ALLOC_MEM(ps, uint32, usr->num_other_sids);
01855                         } else {
01856                                 usr->other_sids = NULL;
01857                                 usr->other_sids_attrib = NULL;
01858                         }
01859 
01860                         if ((num_other_sids != 0) &&
01861                             ((usr->other_sids == NULL) ||
01862                              (usr->other_sids_attrib == NULL)))
01863                                 return False;
01864                 }
01865 
01866                 /* First the pointers to the SIDS and attributes */
01867 
01868                 depth++;
01869 
01870                 for (i=0; i<usr->num_other_sids; i++) {
01871                         uint32 ptr = 1;
01872 
01873                         if (!prs_uint32("sid_ptr", ps, depth, &ptr))
01874                                 return False;
01875 
01876                         if (UNMARSHALLING(ps) && (ptr == 0))
01877                                 return False;
01878 
01879                         if (!prs_uint32("attribute", ps, depth,
01880                                         &usr->other_sids_attrib[i]))
01881                                 return False;
01882                 }
01883         
01884                 for (i = 0; i < usr->num_other_sids; i++) {
01885                         if(!smb_io_dom_sid2("", &usr->other_sids[i], ps, depth)) /* other domain SIDs */
01886                                 return False;
01887                 }
01888 
01889                 depth--;
01890         }
01891 
01892         return True;
01893 }
01894 
01895 /*******************************************************************
01896  Reads or writes a structure.
01897 ********************************************************************/
01898 
01899 BOOL net_io_q_sam_logon(const char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth)
01900 {
01901         if (q_l == NULL)
01902                 return False;
01903 
01904         prs_debug(ps, depth, desc, "net_io_q_sam_logon");
01905         depth++;
01906 
01907         if(!prs_align(ps))
01908                 return False;
01909         
01910         if(!smb_io_sam_info("", &q_l->sam_id, ps, depth))
01911                 return False;
01912 
01913         if(!prs_align_uint16(ps))
01914                 return False;
01915 
01916         if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))
01917                 return False;
01918 
01919         return True;
01920 }
01921 
01922 /*******************************************************************
01923  Reads or writes a structure.
01924 ********************************************************************/
01925 
01926 BOOL net_io_r_sam_logon(const char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth)
01927 {
01928         if (r_l == NULL)
01929                 return False;
01930 
01931         prs_debug(ps, depth, desc, "net_io_r_sam_logon");
01932         depth++;
01933 
01934         if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */
01935                 return False;
01936         if (&r_l->buffer_creds) {
01937                 if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials.  server time stamp appears to be ignored. */
01938                         return False;
01939         }
01940 
01941         if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value))
01942                 return False;
01943         if(!prs_align(ps))
01944                 return False;
01945 
01946 #if 1 /* W2k always needs this - even for bad passwd. JRA */
01947         if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
01948                 return False;
01949 #else
01950         if (r_l->switch_value != 0) {
01951                 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
01952                         return False;
01953         }
01954 #endif
01955 
01956         if(!prs_uint32("auth_resp   ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */
01957                 return False;
01958 
01959         if(!prs_ntstatus("status      ", ps, depth, &r_l->status))
01960                 return False;
01961 
01962         if(!prs_align(ps))
01963                 return False;
01964 
01965         return True;
01966 }
01967 
01968 /*******************************************************************
01969  Reads or writes a structure.
01970 ********************************************************************/
01971 
01972 BOOL net_io_q_sam_logon_ex(const char *desc, NET_Q_SAM_LOGON_EX *q_l, prs_struct *ps, int depth)
01973 {
01974         if (q_l == NULL)
01975                 return False;
01976 
01977         prs_debug(ps, depth, desc, "net_io_q_sam_logon_ex");
01978         depth++;
01979 
01980         if(!prs_align(ps))
01981                 return False;
01982         
01983         if(!smb_io_sam_info_ex("", &q_l->sam_id, ps, depth))
01984                 return False;
01985 
01986         if(!prs_align_uint16(ps))
01987                 return False;
01988 
01989         if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))
01990                 return False;
01991 
01992         if(!prs_uint32("flags  ", ps, depth, &q_l->flags))
01993                 return False;
01994 
01995         return True;
01996 }
01997 
01998 /*******************************************************************
01999  Reads or writes a structure.
02000 ********************************************************************/
02001 
02002 BOOL net_io_r_sam_logon_ex(const char *desc, NET_R_SAM_LOGON_EX *r_l, prs_struct *ps, int depth)
02003 {
02004         if (r_l == NULL)
02005                 return False;
02006 
02007         prs_debug(ps, depth, desc, "net_io_r_sam_logon_ex");
02008         depth++;
02009 
02010         if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value))
02011                 return False;
02012         if(!prs_align(ps))
02013                 return False;
02014 
02015 #if 1 /* W2k always needs this - even for bad passwd. JRA */
02016         if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
02017                 return False;
02018 #else
02019         if (r_l->switch_value != 0) {
02020                 if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))
02021                         return False;
02022         }
02023 #endif
02024 
02025         if(!prs_uint32("auth_resp   ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */
02026                 return False;
02027 
02028         if(!prs_uint32("flags   ", ps, depth, &r_l->flags))
02029                 return False;
02030 
02031         if(!prs_ntstatus("status      ", ps, depth, &r_l->status))
02032                 return False;
02033 
02034         if(!prs_align(ps))
02035                 return False;
02036 
02037         return True;
02038 }
02039 
02040 
02041 /*******************************************************************
02042  Reads or writes a structure.
02043 ********************************************************************/
02044 
02045 BOOL net_io_q_sam_logoff(const char *desc,  NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth)
02046 {
02047         if (q_l == NULL)
02048                 return False;
02049 
02050         prs_debug(ps, depth, desc, "net_io_q_sam_logoff");
02051         depth++;
02052 
02053         if(!prs_align(ps))
02054                 return False;
02055         
02056         if(!smb_io_sam_info("", &q_l->sam_id, ps, depth))           /* domain SID */
02057                 return False;
02058 
02059         return True;
02060 }
02061 
02062 /*******************************************************************
02063  Reads or writes a structure.
02064 ********************************************************************/
02065 
02066 BOOL net_io_r_sam_logoff(const char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth)
02067 {
02068         if (r_l == NULL)
02069                 return False;
02070 
02071         prs_debug(ps, depth, desc, "net_io_r_sam_logoff");
02072         depth++;
02073 
02074         if(!prs_align(ps))
02075                 return False;
02076         
02077         if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */
02078                 return False;
02079         if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials.  server time stamp appears to be ignored. */
02080                 return False;
02081 
02082         if(!prs_ntstatus("status      ", ps, depth, &r_l->status))
02083                 return False;
02084 
02085         return True;
02086 }
02087 
02088 /*******************************************************************
02089 makes a NET_Q_SAM_SYNC structure.
02090 ********************************************************************/
02091 BOOL init_net_q_sam_sync(NET_Q_SAM_SYNC * q_s, const char *srv_name,
02092                          const char *cli_name, DOM_CRED *cli_creds, 
02093                          DOM_CRED *ret_creds, uint32 database_id, 
02094                          uint32 next_rid)
02095 {
02096         DEBUG(5, ("init_q_sam_sync\n"));
02097 
02098         init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
02099         init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
02100 
02101         if (cli_creds)
02102                 memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
02103 
02104         if (cli_creds)
02105                 memcpy(&q_s->ret_creds, ret_creds, sizeof(q_s->ret_creds));
02106         else
02107                 memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
02108 
02109         q_s->database_id = database_id;
02110         q_s->restart_state = 0;
02111         q_s->sync_context = next_rid;
02112         q_s->max_size = 0xffff;
02113 
02114         return True;
02115 }
02116 
02117 /*******************************************************************
02118 reads or writes a structure.
02119 ********************************************************************/
02120 BOOL net_io_q_sam_sync(const char *desc, NET_Q_SAM_SYNC * q_s, prs_struct *ps,
02121                        int depth)
02122 {
02123         prs_debug(ps, depth, desc, "net_io_q_sam_sync");
02124         depth++;
02125 
02126         if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth))
02127                 return False;
02128         if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth))
02129                 return False;
02130 
02131         if (!smb_io_cred("", &q_s->cli_creds, ps, depth))
02132                 return False;
02133         if (!smb_io_cred("", &q_s->ret_creds, ps, depth))
02134                 return False;
02135 
02136         if (!prs_uint32("database_id  ", ps, depth, &q_s->database_id))
02137                 return False;
02138         if (!prs_uint32("restart_state", ps, depth, &q_s->restart_state))
02139                 return False;
02140         if (!prs_uint32("sync_context ", ps, depth, &q_s->sync_context))
02141                 return False;
02142 
02143         if (!prs_uint32("max_size", ps, depth, &q_s->max_size))
02144                 return False;
02145 
02146         return True;
02147 }
02148 
02149 /*******************************************************************
02150 reads or writes a structure.
02151 ********************************************************************/
02152 static BOOL net_io_sam_delta_hdr(const char *desc, SAM_DELTA_HDR * delta,
02153                                  prs_struct *ps, int depth)
02154 {
02155         prs_debug(ps, depth, desc, "net_io_sam_delta_hdr");
02156         depth++;
02157 
02158         if (!prs_uint16("type", ps, depth, &delta->type))
02159                 return False;
02160         if (!prs_uint16("type2", ps, depth, &delta->type2))
02161                 return False;
02162         if (!prs_uint32("target_rid", ps, depth, &delta->target_rid))
02163                 return False;
02164 
02165         if (!prs_uint32("type3", ps, depth, &delta->type3))
02166                 return False;
02167 
02168         /* Not sure why we need this but it seems to be necessary to get
02169            sam deltas working. */
02170 
02171         if (delta->type != 0x16) {
02172                 if (!prs_uint32("ptr_delta", ps, depth, &delta->ptr_delta))
02173                         return False;
02174         }
02175 
02176         return True;
02177 }
02178 
02179 /*******************************************************************
02180 reads or writes a structure.
02181 ********************************************************************/
02182 static BOOL net_io_sam_delta_mod_count(const char *desc, SAM_DELTA_MOD_COUNT *info,
02183                                    prs_struct *ps, int depth)
02184 {
02185         prs_debug(ps, depth, desc, "net_io_sam_delta_stamp");
02186         depth++;
02187 
02188         if (!prs_uint32("seqnum", ps, depth, &info->seqnum))
02189                 return False;
02190         if (!prs_uint32("dom_mod_count_ptr", ps, depth, 
02191                         &info->dom_mod_count_ptr))
02192                 return False;
02193 
02194         if (info->dom_mod_count_ptr) {
02195                 if (!prs_uint64("dom_mod_count", ps, depth,
02196                                 &info->dom_mod_count))
02197                         return False;
02198         }
02199 
02200         return True;
02201 }
02202 
02203 /*******************************************************************
02204 reads or writes a structure.
02205 ********************************************************************/
02206 static BOOL net_io_sam_domain_info(const char *desc, SAM_DOMAIN_INFO * info,
02207                                    prs_struct *ps, int depth)
02208 {
02209         prs_debug(ps, depth, desc, "net_io_sam_domain_info");
02210         depth++;
02211 
02212         if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth))
02213                 return False;
02214         if (!smb_io_unihdr("hdr_oem_info", &info->hdr_oem_info, ps, depth))
02215                 return False;
02216 
02217         if (!prs_uint64("force_logoff", ps, depth, &info->force_logoff))
02218                 return False;
02219         if (!prs_uint16("min_pwd_len", ps, depth, &info->min_pwd_len))
02220                 return False;
02221         if (!prs_uint16("pwd_history_len", ps, depth, &info->pwd_history_len))
02222                 return False;
02223         if (!prs_uint64("max_pwd_age", ps, depth, &info->max_pwd_age))
02224                 return False;
02225         if (!prs_uint64("min_pwd_age", ps, depth, &info->min_pwd_age))
02226                 return False;
02227         if (!prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count))
02228                 return False;
02229         if (!smb_io_time("creation_time", &info->creation_time, ps, depth))
02230                 return False;
02231         if (!prs_uint32("security_information", ps, depth, &info->security_information))
02232                 return False;
02233         if (!smb_io_bufhdr4("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
02234                 return False;
02235         if (!smb_io_lockout_string_hdr("hdr_account_lockout_string", &info->hdr_account_lockout, ps, depth))
02236                 return False;
02237         if (!smb_io_unihdr("hdr_unknown2", &info->hdr_unknown2, ps, depth))
02238                 return False;
02239         if (!smb_io_unihdr("hdr_unknown3", &info->hdr_unknown3, ps, depth))
02240                 return False;
02241         if (!smb_io_unihdr("hdr_unknown4", &info->hdr_unknown4, ps, depth))
02242                 return False;
02243         if (!prs_uint32("logon_chgpass", ps, depth, &info->logon_chgpass))
02244                 return False;
02245         if (!prs_uint32("unknown6", ps, depth, &info->unknown6))
02246                 return False;
02247         if (!prs_uint32("unknown7", ps, depth, &info->unknown7))
02248                 return False;
02249         if (!prs_uint32("unknown8", ps, depth, &info->unknown8))
02250                 return False;
02251 
02252         if (!smb_io_unistr2("uni_dom_name", &info->uni_dom_name,
02253                             info->hdr_dom_name.buffer, ps, depth))
02254                 return False;
02255         if (!smb_io_unistr2("buf_oem_info", &info->buf_oem_info,
02256                             info->hdr_oem_info.buffer, ps, depth))
02257                 return False;
02258 
02259         if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
02260                 return False;
02261 
02262         if (!smb_io_account_lockout_str("account_lockout", &info->account_lockout, 
02263                                         info->hdr_account_lockout.buffer, ps, depth))
02264                 return False;
02265 
02266         if (!smb_io_unistr2("buf_unknown2", &info->buf_unknown2, 
02267                             info->hdr_unknown2.buffer, ps, depth))
02268                 return False;
02269         if (!smb_io_unistr2("buf_unknown3", &info->buf_unknown3, 
02270                             info->hdr_unknown3.buffer, ps, depth))
02271                 return False;
02272         if (!smb_io_unistr2("buf_unknown4", &info->buf_unknown4, 
02273                             info->hdr_unknown4.buffer, ps, depth))
02274                 return False;
02275 
02276         return True;
02277 }
02278 
02279 /*******************************************************************
02280 reads or writes a structure.
02281 ********************************************************************/
02282 static BOOL net_io_sam_group_info(const char *desc, SAM_GROUP_INFO * info,
02283                                   prs_struct *ps, int depth)
02284 {
02285         prs_debug(ps, depth, desc, "net_io_sam_group_info");
02286         depth++;
02287 
02288         if (!smb_io_unihdr("hdr_grp_name", &info->hdr_grp_name, ps, depth))
02289                 return False;
02290         if (!smb_io_gid("gid", &info->gid, ps, depth))
02291                 return False;
02292         if (!smb_io_unihdr("hdr_grp_desc", &info->hdr_grp_desc, ps, depth))
02293                 return False;
02294         if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
02295                 return False;
02296 
02297         if (ps->data_offset + 48 > ps->buffer_size)
02298                 return False;
02299         ps->data_offset += 48;
02300 
02301         if (!smb_io_unistr2("uni_grp_name", &info->uni_grp_name,
02302                             info->hdr_grp_name.buffer, ps, depth))
02303                 return False;
02304         if (!smb_io_unistr2("uni_grp_desc", &info->uni_grp_desc,
02305                             info->hdr_grp_desc.buffer, ps, depth))
02306                 return False;
02307         if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
02308                 return False;
02309 
02310         return True;
02311 }
02312 
02313 /*******************************************************************
02314 reads or writes a structure.
02315 ********************************************************************/
02316 static BOOL net_io_sam_passwd_info(const char *desc, SAM_PWD * pwd,
02317                                    prs_struct *ps, int depth)
02318 {
02319         prs_debug(ps, depth, desc, "net_io_sam_passwd_info");
02320         depth++;
02321 
02322         if (!prs_uint32("unk_0 ", ps, depth, &pwd->unk_0))
02323                 return False;
02324 
02325         if (!smb_io_unihdr("hdr_lm_pwd", &pwd->hdr_lm_pwd, ps, depth))
02326                 return False;
02327         if (!prs_uint8s(False, "buf_lm_pwd", ps, depth, pwd->buf_lm_pwd, 16))
02328                 return False;
02329 
02330         if (!smb_io_unihdr("hdr_nt_pwd", &pwd->hdr_nt_pwd, ps, depth))
02331                 return False;
02332         if (!prs_uint8s(False, "buf_nt_pwd", ps, depth, pwd->buf_nt_pwd, 16))
02333                 return False;
02334 
02335         if (!smb_io_unihdr("", &pwd->hdr_empty_lm, ps, depth))
02336                 return False;
02337         if (!smb_io_unihdr("", &pwd->hdr_empty_nt, ps, depth))
02338                 return False;
02339 
02340         return True;
02341 }
02342 
02343 /*******************************************************************
02344 reads or writes a structure.
02345 ********************************************************************/
02346 static BOOL net_io_sam_account_info(const char *desc, SAM_ACCOUNT_INFO *info,
02347                                 prs_struct *ps, int depth)
02348 {
02349         BUFHDR2 hdr_priv_data;
02350         uint32 i;
02351 
02352         prs_debug(ps, depth, desc, "net_io_sam_account_info");
02353         depth++;
02354 
02355         if (!smb_io_unihdr("hdr_acct_name", &info->hdr_acct_name, ps, depth))
02356                 return False;
02357         if (!smb_io_unihdr("hdr_full_name", &info->hdr_full_name, ps, depth))
02358                 return False;
02359 
02360         if (!prs_uint32("user_rid ", ps, depth, &info->user_rid))
02361                 return False;
02362         if (!prs_uint32("group_rid", ps, depth, &info->group_rid))
02363                 return False;
02364 
02365         if (!smb_io_unihdr("hdr_home_dir ", &info->hdr_home_dir, ps, depth))
02366                 return False;
02367         if (!smb_io_unihdr("hdr_dir_drive", &info->hdr_dir_drive, ps, depth))
02368                 return False;
02369         if (!smb_io_unihdr("hdr_logon_script", &info->hdr_logon_script, ps,
02370                            depth))
02371                 return False;
02372 
02373         if (!smb_io_unihdr("hdr_acct_desc", &info->hdr_acct_desc, ps, depth))
02374                 return False;
02375         if (!smb_io_unihdr("hdr_workstations", &info->hdr_workstations, ps,
02376                            depth))
02377                 return False;
02378 
02379         if (!smb_io_time("logon_time", &info->logon_time, ps, depth))
02380                 return False;
02381         if (!smb_io_time("logoff_time", &info->logoff_time, ps, depth))
02382                 return False;
02383 
02384         if (!prs_uint32("logon_divs   ", ps, depth, &info->logon_divs))
02385                 return False;
02386         if (!prs_uint32("ptr_logon_hrs", ps, depth, &info->ptr_logon_hrs))
02387                 return False;
02388 
02389         if (!prs_uint16("bad_pwd_count", ps, depth, &info->bad_pwd_count))
02390                 return False;
02391         if (!prs_uint16("logon_count", ps, depth, &info->logon_count))
02392                 return False;
02393         if (!smb_io_time("pwd_last_set_time", &info->pwd_last_set_time, ps,
02394                          depth))
02395                 return False;
02396         if (!smb_io_time("acct_expiry_time", &info->acct_expiry_time, ps, 
02397                          depth))
02398                 return False;
02399 
02400         if (!prs_uint32("acb_info", ps, depth, &info->acb_info))
02401                 return False;
02402         if (!prs_uint8s(False, "nt_pwd", ps, depth, info->nt_pwd, 16))
02403                 return False;
02404         if (!prs_uint8s(False, "lm_pwd", ps, depth, info->lm_pwd, 16))
02405                 return False;
02406         if (!prs_uint8("lm_pwd_present", ps, depth, &info->lm_pwd_present))
02407                 return False;
02408         if (!prs_uint8("nt_pwd_present", ps, depth, &info->nt_pwd_present))
02409                 return False;
02410         if (!prs_uint8("pwd_expired", ps, depth, &info->pwd_expired))
02411                 return False;
02412 
02413         if (!smb_io_unihdr("hdr_comment", &info->hdr_comment, ps, depth))
02414                 return False;
02415         if (!smb_io_unihdr("hdr_parameters", &info->hdr_parameters, ps, 
02416                            depth))
02417                 return False;
02418         if (!prs_uint16("country", ps, depth, &info->country))
02419                 return False;
02420         if (!prs_uint16("codepage", ps, depth, &info->codepage))
02421                 return False;
02422 
02423         if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data, ps, depth))
02424                 return False;
02425         if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
02426                 return False;
02427         if (!smb_io_unihdr("hdr_profile", &info->hdr_profile, ps, depth))
02428                 return False;
02429 
02430         for (i = 0; i < 3; i++)
02431         {
02432                 if (!smb_io_unihdr("hdr_reserved", &info->hdr_reserved[i], 
02433                                    ps, depth))
02434                         return False;                                          
02435         }
02436 
02437         for (i = 0; i < 4; i++)
02438         {
02439                 if (!prs_uint32("dw_reserved", ps, depth, 
02440                                 &info->dw_reserved[i]))
02441                         return False;
02442         }
02443 
02444         if (!smb_io_unistr2("uni_acct_name", &info->uni_acct_name,
02445                             info->hdr_acct_name.buffer, ps, depth))
02446                 return False;
02447         prs_align(ps);
02448         if (!smb_io_unistr2("uni_full_name", &info->uni_full_name,
02449                             info->hdr_full_name.buffer, ps, depth))
02450                 return False;
02451         prs_align(ps);
02452         if (!smb_io_unistr2("uni_home_dir ", &info->uni_home_dir,
02453                             info->hdr_home_dir.buffer, ps, depth))
02454                 return False;
02455         prs_align(ps);
02456         if (!smb_io_unistr2("uni_dir_drive", &info->uni_dir_drive,
02457                             info->hdr_dir_drive.buffer, ps, depth))
02458                 return False;
02459         prs_align(ps);
02460         if (!smb_io_unistr2("uni_logon_script", &info->uni_logon_script,
02461                             info->hdr_logon_script.buffer, ps, depth))
02462                 return False;
02463         prs_align(ps);
02464         if (!smb_io_unistr2("uni_acct_desc", &info->uni_acct_desc,
02465                             info->hdr_acct_desc.buffer, ps, depth))
02466                 return False;
02467         prs_align(ps);
02468         if (!smb_io_unistr2("uni_workstations", &info->uni_workstations,
02469                             info->hdr_workstations.buffer, ps, depth))
02470                 return False;
02471         prs_align(ps);
02472 
02473         if (!prs_uint32("unknown1", ps, depth, &info->unknown1))
02474                 return False;
02475         if (!prs_uint32("unknown2", ps, depth, &info->unknown2))
02476                 return False;
02477 
02478         if (!smb_io_rpc_blob("buf_logon_hrs", &info->buf_logon_hrs, ps, depth))
02479                 return False;
02480         prs_align(ps);
02481         if (!smb_io_unistr2("uni_comment", &info->uni_comment,
02482                             info->hdr_comment.buffer, ps, depth))
02483                 return False;
02484         prs_align(ps);
02485         if (!smb_io_unistr2("uni_parameters", &info->uni_parameters,
02486                             info->hdr_parameters.buffer, ps, depth))
02487                 return False;
02488         prs_align(ps);
02489         if (hdr_priv_data.buffer != 0)
02490         {
02491                 int old_offset = 0;
02492                 uint32 len = 0x44;
02493                 if (!prs_uint32("pwd_len", ps, depth, &len))
02494                         return False;
02495                 old_offset = ps->data_offset;
02496                 if (len > 0)
02497                 {
02498                         if (ps->io)
02499                         {
02500                                 /* reading */
02501                                 if (!prs_hash1(ps, ps->data_offset, len))
02502                                         return False;
02503                         }
02504                         if (!net_io_sam_passwd_info("pass", &info->pass, 
02505                                                     ps, depth))
02506                                 return False;
02507 
02508                         if (!ps->io)
02509                         {
02510                                 /* writing */
02511                                 if (!prs_hash1(ps, old_offset, len))
02512                                         return False;
02513                         }
02514                 }
02515                 if (old_offset + len > ps->buffer_size)
02516                         return False;
02517                 ps->data_offset = old_offset + len;
02518         }
02519         if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
02520                 return False;
02521         prs_align(ps);
02522         if (!smb_io_unistr2("uni_profile", &info->uni_profile,
02523                             info->hdr_profile.buffer, ps, depth))
02524                 return False;
02525 
02526         prs_align(ps);
02527 
02528         return True;
02529 }
02530 
02531 /*******************************************************************
02532 reads or writes a structure.
02533 ********************************************************************/
02534 static BOOL net_io_sam_group_mem_info(const char *desc, SAM_GROUP_MEM_INFO * info,
02535                                       prs_struct *ps, int depth)
02536 {
02537         uint32 i;
02538         fstring tmp;
02539 
02540         prs_debug(ps, depth, desc, "net_io_sam_group_mem_info");
02541         depth++;
02542 
02543         prs_align(ps);
02544         if (!prs_uint32("ptr_rids   ", ps, depth, &info->ptr_rids))
02545                 return False;
02546         if (!prs_uint32("ptr_attribs", ps, depth, &info->ptr_attribs))
02547                 return False;
02548         if (!prs_uint32("num_members", ps, depth, &info->num_members))
02549                 return False;
02550 
02551         if (ps->data_offset + 16 > ps->buffer_size)
02552                 return False;
02553         ps->data_offset += 16;
02554 
02555         if (info->ptr_rids != 0)
02556         {
02557                 if (!prs_uint32("num_members2", ps, depth, 
02558                                 &info->num_members2))
02559                         return False;
02560 
02561                 if (info->num_members2 != info->num_members)
02562                 {
02563                         /* RPC fault */
02564                         return False;
02565                 }
02566 
02567                 if (UNMARSHALLING(ps)) {
02568                         if (info->num_members2) {
02569                                 info->rids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members2);
02570 
02571                                 if (info->rids == NULL) {
02572                                         DEBUG(0, ("out of memory allocating %d rids\n",
02573                                                 info->num_members2));
02574                                         return False;
02575                                 }
02576                         } else {
02577                                 info->rids = NULL;
02578                         }
02579                 }
02580 
02581                 for (i = 0; i < info->num_members2; i++)
02582                 {
02583                         slprintf(tmp, sizeof(tmp) - 1, "rids[%02d]", i);
02584                         if (!prs_uint32(tmp, ps, depth, &info->rids[i]))
02585                                 return False;
02586                 }
02587         }
02588 
02589         if (info->ptr_attribs != 0)
02590         {
02591                 if (!prs_uint32("num_members3", ps, depth, 
02592                                 &info->num_members3))
02593                         return False;
02594                 if (info->num_members3 != info->num_members)
02595                 {
02596                         /* RPC fault */
02597                         return False;
02598                 }
02599 
02600                 if (UNMARSHALLING(ps)) {
02601                         if (info->num_members3) {
02602                                 info->attribs = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members3);
02603 
02604                                 if (info->attribs == NULL) {
02605                                         DEBUG(0, ("out of memory allocating %d attribs\n",
02606                                                 info->num_members3));
02607                                         return False;
02608                                 }
02609                         } else {
02610                                 info->attribs = NULL;
02611                         }
02612                 }       
02613 
02614                 for (i = 0; i < info->num_members3; i++)
02615                 {
02616                         slprintf(tmp, sizeof(tmp) - 1, "attribs[%02d]", i);
02617                         if (!prs_uint32(tmp, ps, depth, &info->attribs[i]))
02618                                 return False;
02619                 }
02620         }
02621 
02622         return True;
02623 }
02624 
02625 /*******************************************************************
02626 reads or writes a structure.
02627 ********************************************************************/
02628 static BOOL net_io_sam_alias_info(const char *desc, SAM_ALIAS_INFO * info,
02629                                   prs_struct *ps, int depth)
02630 {
02631         prs_debug(ps, depth, desc, "net_io_sam_alias_info");
02632         depth++;
02633 
02634         if (!smb_io_unihdr("hdr_als_name", &info->hdr_als_name, ps, depth))
02635                 return False;
02636         if (!prs_uint32("als_rid", ps, depth, &info->als_rid))
02637                 return False;
02638         if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
02639                 return False;
02640         if (!smb_io_unihdr("hdr_als_desc", &info->hdr_als_desc, ps, depth))
02641                 return False;
02642 
02643         if (ps->data_offset + 40 > ps->buffer_size)
02644                 return False;
02645         ps->data_offset += 40;
02646 
02647         if (!smb_io_unistr2("uni_als_name", &info->uni_als_name,
02648                             info->hdr_als_name.buffer, ps, depth))
02649                 return False;
02650         if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
02651                 return False;
02652 
02653         if (!smb_io_unistr2("uni_als_desc", &info->uni_als_desc,
02654                             info->hdr_als_desc.buffer, ps, depth))
02655                 return False;
02656 
02657         return True;
02658 }
02659 
02660 /*******************************************************************
02661 reads or writes a structure.
02662 ********************************************************************/
02663 static BOOL net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * info,
02664                                       prs_struct *ps, int depth)
02665 {
02666         uint32 i;
02667         fstring tmp;
02668 
02669         prs_debug(ps, depth, desc, "net_io_sam_alias_mem_info");
02670         depth++;
02671 
02672         prs_align(ps);
02673         if (!prs_uint32("num_members", ps, depth, &info->num_members))
02674                 return False;
02675         if (!prs_uint32("ptr_members", ps, depth, &info->ptr_members))
02676                 return False;
02677 
02678         if (ps->data_offset + 16 > ps->buffer_size)
02679                 return False;
02680         ps->data_offset += 16;
02681 
02682         if (info->ptr_members != 0)
02683         {
02684                 if (!prs_uint32("num_sids", ps, depth, &info->num_sids))
02685                         return False;
02686                 if (info->num_sids != info->num_members)
02687                 {
02688                         /* RPC fault */
02689                         return False;
02690                 }
02691 
02692                 if (UNMARSHALLING(ps)) {
02693                         if (info->num_sids) {
02694                                 info->ptr_sids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_sids);
02695                 
02696                                 if (info->ptr_sids == NULL) {
02697                                         DEBUG(0, ("out of memory allocating %d ptr_sids\n",
02698                                                 info->num_sids));
02699                                         return False;
02700                                 }
02701                         } else {
02702                                 info->ptr_sids = NULL;
02703                         }
02704                 }
02705 
02706                 for (i = 0; i < info->num_sids; i++)
02707                 {
02708                         slprintf(tmp, sizeof(tmp) - 1, "ptr_sids[%02d]", i);
02709                         if (!prs_uint32(tmp, ps, depth, &info->ptr_sids[i]))
02710                                 return False;
02711                 }
02712 
02713                 if (UNMARSHALLING(ps)) {
02714                         if (info->num_sids) {
02715                                 info->sids = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, info->num_sids);
02716 
02717                                 if (info->sids == NULL) {
02718                                         DEBUG(0, ("error allocating %d sids\n",
02719                                                 info->num_sids));
02720                                         return False;
02721                                 }
02722                         } else {
02723                                 info->sids = NULL;
02724                         }
02725                 }
02726 
02727                 for (i = 0; i < info->num_sids; i++)
02728                 {
02729                         if (info->ptr_sids[i] != 0)
02730                         {
02731                                 slprintf(tmp, sizeof(tmp) - 1, "sids[%02d]",
02732                                          i);
02733                                 if (!smb_io_dom_sid2(tmp, &info->sids[i], 
02734                                                      ps, depth))
02735                                         return False;
02736                         }
02737                 }
02738         }
02739 
02740         return True;
02741 }
02742 
02743 /*******************************************************************
02744 reads or writes a structure.
02745 ********************************************************************/
02746 static BOOL net_io_sam_policy_info(const char *desc, SAM_DELTA_POLICY *info,
02747                                       prs_struct *ps, int depth)
02748 {
02749         unsigned int i;
02750         prs_debug(ps, depth, desc, "net_io_sam_policy_info");
02751         depth++;
02752 
02753         if(!prs_align(ps))
02754                 return False;
02755 
02756         if (!prs_uint32("max_log_size", ps, depth, &info->max_log_size))
02757                 return False;
02758         if (!prs_uint64("audit_retention_period", ps, depth,
02759                         &info->audit_retention_period))
02760                 return False;
02761         if (!prs_uint32("auditing_mode", ps, depth, &info->auditing_mode))
02762                 return False;
02763         if (!prs_uint32("num_events", ps, depth, &info->num_events))
02764                 return False;
02765         if (!prs_uint32("ptr_events", ps, depth, &info->ptr_events))
02766                 return False;
02767 
02768         if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth))
02769                 return False;
02770 
02771         if (!prs_uint32("sid_ptr", ps, depth, &info->sid_ptr))
02772                 return False;
02773 
02774         if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit))
02775                 return False;
02776         if (!prs_uint32("non_paged_pool_limit", ps, depth,
02777                         &info->non_paged_pool_limit))
02778                 return False;
02779         if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size))
02780                 return False;
02781         if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size))
02782                 return False;
02783         if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit))
02784                 return False;
02785         if (!prs_uint64("time_limit", ps, depth, &info->time_limit))
02786                 return False;
02787         if (!smb_io_time("modify_time", &info->modify_time, ps, depth))
02788                 return False;
02789         if (!smb_io_time("create_time", &info->create_time, ps, depth))
02790                 return False;
02791         if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
02792                 return False;
02793 
02794         for (i=0; i<4; i++) {
02795                 UNIHDR dummy;
02796                 if (!smb_io_unihdr("dummy", &dummy, ps, depth))
02797                         return False;
02798         }
02799 
02800         for (i=0; i<4; i++) {
02801                 uint32 reserved;
02802                 if (!prs_uint32("reserved", ps, depth, &reserved))
02803                         return False;
02804         }
02805 
02806         if (!prs_uint32("num_event_audit_options", ps, depth,
02807                         &info->num_event_audit_options))
02808                 return False;
02809 
02810         for (i=0; i<info->num_event_audit_options; i++)
02811                 if (!prs_uint32("event_audit_option", ps, depth,
02812                                 &info->event_audit_option))
02813                         return False;
02814 
02815         if (!smb_io_unistr2("domain_name", &info->domain_name, True, ps, depth))
02816                 return False;
02817 
02818         if(!smb_io_dom_sid2("domain_sid", &info->domain_sid, ps, depth))
02819                 return False;
02820 
02821         if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
02822 
02823                 return False;
02824 
02825         return True;
02826 }
02827 
02828 #if 0
02829 
02830 /* This function is pretty broken - see bug #334 */
02831 
02832 /*******************************************************************
02833 reads or writes a structure.
02834 ********************************************************************/
02835 static BOOL net_io_sam_trustdoms_info(const char *desc, SAM_DELTA_TRUSTDOMS *info,
02836                                       prs_struct *ps, int depth)
02837 {
02838         int i;
02839 
02840         prs_debug(ps, depth, desc, "net_io_sam_trustdoms_info");
02841         depth++;
02842 
02843         if(!prs_align(ps))
02844                 return False;
02845 
02846         if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
02847                 return False;
02848 
02849         if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
02850                 return False;
02851 
02852         if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
02853                 return False;
02854 
02855         if(!smb_io_unihdr("hdr_domain", &info->hdr_domain, ps, depth))
02856                 return False;
02857 
02858         if(!prs_uint32("unknown0", ps, depth, &info->unknown0))
02859                 return False;
02860         if(!prs_uint32("unknown1", ps, depth, &info->unknown1))
02861                 return False;
02862         if(!prs_uint32("unknown2", ps, depth, &info->unknown2))
02863                 return False;
02864 
02865         if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
02866                 return False;
02867         if(!prs_uint32("ptr", ps, depth, &info->ptr))
02868                 return False;
02869 
02870         for (i=0; i<12; i++)
02871                 if(!prs_uint32("unknown3", ps, depth, &info->unknown3))
02872                         return False;
02873 
02874         if (!smb_io_unistr2("domain", &info->domain, True, ps, depth))
02875                 return False;
02876 
02877         return True;
02878 }
02879 
02880 #endif
02881 
02882 #if 0
02883 
02884 /* This function doesn't work - see bug #334 */
02885 
02886 /*******************************************************************
02887 reads or writes a structure.
02888 ********************************************************************/
02889 static BOOL net_io_sam_secret_info(const char *desc, SAM_DELTA_SECRET *info,
02890                                    prs_struct *ps, int depth)
02891 {
02892         int i;
02893 
02894         prs_debug(ps, depth, desc, "net_io_sam_secret_info");
02895         depth++;
02896 
02897         if(!prs_align(ps))
02898                 return False;
02899 
02900         if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
02901                 return False;
02902 
02903         if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
02904                 return False;
02905 
02906         if (!smb_io_unistr2("secret", &info->secret, True, ps, depth))
02907                 return False;
02908 
02909         if(!prs_align(ps))
02910                 return False;
02911 
02912         if(!prs_uint32("count1", ps, depth, &info->count1))
02913                 return False;
02914         if(!prs_uint32("count2", ps, depth, &info->count2))
02915                 return False;
02916         if(!prs_uint32("ptr", ps, depth, &info->ptr))
02917                 return False;
02918 
02919 
02920         if(!smb_io_time("time1", &info->time1, ps, depth)) /* logon time */
02921                 return False;
02922         if(!prs_uint32("count3", ps, depth, &info->count3))
02923                 return False;
02924         if(!prs_uint32("count4", ps, depth, &info->count4))
02925                 return False;
02926         if(!prs_uint32("ptr2", ps, depth, &info->ptr2))
02927                 return False;
02928         if(!smb_io_time("time2", &info->time2, ps, depth)) /* logon time */
02929                 return False;
02930         if(!prs_uint32("unknow1", ps, depth, &info->unknow1))
02931                 return False;
02932 
02933 
02934         if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
02935                 return False;
02936         if(!prs_uint32("ptr3", ps, depth, &info->ptr3))
02937                 return False;
02938         for(i=0; i<12; i++)
02939                 if(!prs_uint32("unknow2", ps, depth, &info->unknow2))
02940                         return False;
02941 
02942         if(!prs_uint32("chal_len", ps, depth, &info->chal_len))
02943                 return False;
02944         if(!prs_uint32("reserved1", ps, depth, &info->reserved1))
02945                 return False;
02946         if(!prs_uint32("chal_len2", ps, depth, &info->chal_len2))
02947                 return False;
02948 
02949         if(!prs_uint8s (False, "chal", ps, depth, info->chal, info->chal_len2))
02950                 return False;
02951 
02952         if(!prs_uint32("key_len", ps, depth, &info->key_len))
02953                 return False;
02954         if(!prs_uint32("reserved2", ps, depth, &info->reserved2))
02955                 return False;
02956         if(!prs_uint32("key_len2", ps, depth, &info->key_len2))
02957                 return False;
02958 
02959         if(!prs_uint8s (False, "key", ps, depth, info->key, info->key_len2))
02960                 return False;
02961 
02962 
02963         if(!prs_uint32("buf_size3", ps, depth, &info->buf_size3))
02964                 return False;
02965 
02966         if(!sec_io_desc("sec_desc2", &info->sec_desc2, ps, depth))
02967                 return False;
02968 
02969 
02970         return True;
02971 }
02972 
02973 #endif
02974 
02975 /*******************************************************************
02976 reads or writes a structure.
02977 ********************************************************************/
02978 static BOOL net_io_sam_privs_info(const char *desc, SAM_DELTA_PRIVS *info,
02979                                       prs_struct *ps, int depth)
02980 {
02981         unsigned int i;
02982 
02983         prs_debug(ps, depth, desc, "net_io_sam_privs_info");
02984         depth++;
02985 
02986         if(!prs_align(ps))
02987                 return False;
02988 
02989         if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
02990                 return False;
02991 
02992         if(!prs_uint32("priv_count", ps, depth, &info->priv_count))
02993                 return False;
02994         if(!prs_uint32("priv_control", ps, depth, &info->priv_control))
02995                 return False;
02996 
02997         if(!prs_uint32("priv_attr_ptr", ps, depth, &info->priv_attr_ptr))
02998                 return False;
02999         if(!prs_uint32("priv_name_ptr", ps, depth, &info->priv_name_ptr))
03000                 return False;
03001 
03002         if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit))
03003                 return False;
03004         if (!prs_uint32("non_paged_pool_limit", ps, depth,
03005                         &info->non_paged_pool_limit))
03006                 return False;
03007         if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size))
03008                 return False;
03009         if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size))
03010                 return False;
03011         if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit))
03012                 return False;
03013         if (!prs_uint64("time_limit", ps, depth, &info->time_limit))
03014                 return False;
03015         if (!prs_uint32("system_flags", ps, depth, &info->system_flags))
03016                 return False;
03017         if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
03018                 return False;
03019 
03020         for (i=0; i<4; i++) {
03021                 UNIHDR dummy;
03022                 if (!smb_io_unihdr("dummy", &dummy, ps, depth))
03023                         return False;
03024         }
03025 
03026         for (i=0; i<4; i++) {
03027                 uint32 reserved;
03028                 if (!prs_uint32("reserved", ps, depth, &reserved))
03029                         return False;
03030         }
03031 
03032         if(!prs_uint32("attribute_count", ps, depth, &info->attribute_count))
03033                 return False;
03034 
03035         if (UNMARSHALLING(ps)) {
03036                 if (info->attribute_count) {
03037                         info->attributes = TALLOC_ARRAY(ps->mem_ctx, uint32, info->attribute_count);
03038                         if (!info->attributes) {
03039                                 return False;
03040                         }
03041                 } else {
03042                         info->attributes = NULL;
03043                 }
03044         }
03045 
03046         for (i=0; i<info->attribute_count; i++)
03047                 if(!prs_uint32("attributes", ps, depth, &info->attributes[i]))
03048                         return False;
03049 
03050         if(!prs_uint32("privlist_count", ps, depth, &info->privlist_count))
03051                 return False;
03052 
03053         if (UNMARSHALLING(ps)) {
03054                 if (info->privlist_count) {
03055                         info->hdr_privslist = TALLOC_ARRAY(ps->mem_ctx, UNIHDR, info->privlist_count);
03056                         info->uni_privslist = TALLOC_ARRAY(ps->mem_ctx, UNISTR2, info->privlist_count);
03057                         if (!info->hdr_privslist) {
03058                                 return False;
03059                         }
03060                         if (!info->uni_privslist) {
03061                                 return False;
03062                         }
03063                 } else {
03064                         info->hdr_privslist = NULL;
03065                         info->uni_privslist = NULL;
03066                 }
03067         }
03068 
03069         for (i=0; i<info->privlist_count; i++)
03070                 if(!smb_io_unihdr("hdr_privslist", &info->hdr_privslist[i], ps, depth))
03071                         return False;
03072 
03073         for (i=0; i<info->privlist_count; i++)
03074                 if (!smb_io_unistr2("uni_privslist", &info->uni_privslist[i], True, ps, depth))
03075                         return False;
03076 
03077         if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))
03078                 return False;
03079 
03080         return True;
03081 }
03082 
03083 /*******************************************************************
03084 reads or writes a structure.
03085 ********************************************************************/
03086 static BOOL net_io_sam_delta_ctr(const char *desc,
03087                                  SAM_DELTA_CTR * delta, uint16 type,
03088                                  prs_struct *ps, int depth)
03089 {
03090         prs_debug(ps, depth, desc, "net_io_sam_delta_ctr");
03091         depth++;
03092 
03093         switch (type) {
03094                 /* Seen in sam deltas */
03095                 case SAM_DELTA_MODIFIED_COUNT:
03096                         if (!net_io_sam_delta_mod_count("", &delta->mod_count, ps, depth))
03097                                 return False;
03098                         break;
03099 
03100                 case SAM_DELTA_DOMAIN_INFO:
03101                         if (!net_io_sam_domain_info("", &delta->domain_info, ps, depth))
03102                                 return False;
03103                         break;
03104 
03105                 case SAM_DELTA_GROUP_INFO:
03106                         if (!net_io_sam_group_info("", &delta->group_info, ps, depth))
03107                                 return False;
03108                         break;
03109 
03110                 case SAM_DELTA_ACCOUNT_INFO:
03111                         if (!net_io_sam_account_info("", &delta->account_info, ps, depth))
03112                                 return False;
03113                         break;
03114 
03115                 case SAM_DELTA_GROUP_MEM:
03116                         if (!net_io_sam_group_mem_info("", &delta->grp_mem_info, ps, depth))
03117                                 return False;
03118                         break;
03119 
03120                 case SAM_DELTA_ALIAS_INFO:
03121                         if (!net_io_sam_alias_info("", &delta->alias_info, ps, depth))
03122                                 return False;
03123                         break;
03124 
03125                 case SAM_DELTA_POLICY_INFO:
03126                         if (!net_io_sam_policy_info("", &delta->policy_info, ps, depth))
03127                                 return False;
03128                         break;
03129 
03130                 case SAM_DELTA_ALIAS_MEM:
03131                         if (!net_io_sam_alias_mem_info("", &delta->als_mem_info, ps, depth))
03132                                 return False;
03133                         break;
03134 
03135                 case SAM_DELTA_PRIVS_INFO:
03136                         if (!net_io_sam_privs_info("", &delta->privs_info, ps, depth))
03137                                 return False;
03138                         break;
03139 
03140                         /* These guys are implemented but broken */
03141 
03142                 case SAM_DELTA_TRUST_DOMS:
03143                 case SAM_DELTA_SECRET_INFO:
03144                         break;
03145 
03146                         /* These guys are not implemented yet */
03147 
03148                 case SAM_DELTA_RENAME_GROUP:
03149                 case SAM_DELTA_RENAME_USER:
03150                 case SAM_DELTA_RENAME_ALIAS:
03151                 case SAM_DELTA_DELETE_GROUP:
03152                 case SAM_DELTA_DELETE_USER:
03153                 default:
03154                         DEBUG(0, ("Replication error: Unknown delta type 0x%x\n", type));
03155                         break;
03156         }
03157 
03158         return True;
03159 }
03160 
03161 /*******************************************************************
03162 reads or writes a structure.
03163 ********************************************************************/
03164 BOOL net_io_r_sam_sync(const char *desc,
03165                        NET_R_SAM_SYNC * r_s, prs_struct *ps, int depth)
03166 {
03167         uint32 i;
03168 
03169         prs_debug(ps, depth, desc, "net_io_r_sam_sync");
03170         depth++;
03171 
03172         if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
03173                 return False;
03174         if (!prs_uint32("sync_context", ps, depth, &r_s->sync_context))
03175                 return False;
03176 
03177         if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
03178                 return False;
03179         if (r_s->ptr_deltas != 0)
03180         {
03181                 if (!prs_uint32("num_deltas ", ps, depth, &r_s->num_deltas))
03182                         return False;
03183                 if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->ptr_deltas2))
03184                         return False;
03185                 if (r_s->ptr_deltas2 != 0)
03186                 {
03187                         if (!prs_uint32("num_deltas2", ps, depth,
03188                                         &r_s->num_deltas2))
03189                                 return False;
03190 
03191                         if (r_s->num_deltas2 != r_s->num_deltas)
03192                         {
03193                                 /* RPC fault */
03194                                 return False;
03195                         }
03196 
03197                         if (UNMARSHALLING(ps)) {
03198                                 if (r_s->num_deltas2) {
03199                                         r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas2);
03200                                         if (r_s->hdr_deltas == NULL) {
03201                                                 DEBUG(0, ("error tallocating memory "
03202                                                         "for %d delta headers\n", 
03203                                                         r_s->num_deltas2));
03204                                                 return False;
03205                                         }
03206                                 } else {
03207                                         r_s->hdr_deltas = NULL;
03208                                 }
03209                         }
03210 
03211                         for (i = 0; i < r_s->num_deltas2; i++)
03212                         {
03213                                 if (!net_io_sam_delta_hdr("", 
03214                                                           &r_s->hdr_deltas[i],
03215                                                           ps, depth))
03216                                         return False;
03217                         }
03218 
03219                         if (UNMARSHALLING(ps)) {
03220                                 if (r_s->num_deltas2) {
03221                                         r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas2);
03222                                         if (r_s->deltas == NULL) {
03223                                                 DEBUG(0, ("error tallocating memory "
03224                                                         "for %d deltas\n", 
03225                                                         r_s->num_deltas2));
03226                                                 return False;
03227                                         }
03228                                 } else {
03229                                         r_s->deltas = NULL;
03230                                 }
03231                         }
03232 
03233                         for (i = 0; i < r_s->num_deltas2; i++)
03234                         {
03235                                 if (!net_io_sam_delta_ctr(
03236                                         "", &r_s->deltas[i],
03237                                         r_s->hdr_deltas[i].type3,
03238                                         ps, depth)) {
03239                                         DEBUG(0, ("hmm, failed on i=%d\n", i));
03240                                         return False;
03241                                 }
03242                         }
03243                 }
03244         }
03245 
03246         prs_align(ps);
03247         if (!prs_ntstatus("status", ps, depth, &(r_s->status)))
03248                 return False;
03249 
03250         return True;
03251 }
03252 
03253 /*******************************************************************
03254 makes a NET_Q_SAM_DELTAS structure.
03255 ********************************************************************/
03256 BOOL init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name, 
03257                            const char *cli_name, DOM_CRED *cli_creds, 
03258                            uint32 database_id, uint64 dom_mod_count)
03259 {
03260         DEBUG(5, ("init_net_q_sam_deltas\n"));
03261 
03262         init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
03263         init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
03264 
03265         memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
03266         memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
03267 
03268         q_s->database_id = database_id;
03269     q_s->dom_mod_count = dom_mod_count;
03270         q_s->max_size = 0xffff;
03271 
03272         return True;
03273 }
03274 
03275 /*******************************************************************
03276 reads or writes a structure.
03277 ********************************************************************/
03278 BOOL net_io_q_sam_deltas(const char *desc, NET_Q_SAM_DELTAS *q_s, prs_struct *ps,
03279                          int depth)
03280 {
03281         prs_debug(ps, depth, desc, "net_io_q_sam_deltas");
03282         depth++;
03283 
03284         if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth))
03285                 return False;
03286         if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth))
03287                 return False;
03288 
03289         if (!smb_io_cred("", &q_s->cli_creds, ps, depth))
03290                 return False;
03291         if (!smb_io_cred("", &q_s->ret_creds, ps, depth))
03292                 return False;
03293 
03294         if (!prs_uint32("database_id  ", ps, depth, &q_s->database_id))
03295                 return False;
03296         if (!prs_uint64("dom_mod_count", ps, depth, &q_s->dom_mod_count))
03297                 return False;
03298         if (!prs_uint32("max_size", ps, depth, &q_s->max_size))
03299                 return False;
03300 
03301         return True;
03302 }
03303 
03304 /*******************************************************************
03305 reads or writes a structure.
03306 ********************************************************************/
03307 BOOL net_io_r_sam_deltas(const char *desc,
03308                          NET_R_SAM_DELTAS *r_s, prs_struct *ps, int depth)
03309 {
03310         unsigned int i;
03311 
03312         prs_debug(ps, depth, desc, "net_io_r_sam_deltas");
03313         depth++;
03314 
03315         if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
03316                 return False;
03317         if (!prs_uint64("dom_mod_count", ps, depth, &r_s->dom_mod_count))
03318                 return False;
03319 
03320         if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
03321                 return False;
03322         if (!prs_uint32("num_deltas", ps, depth, &r_s->num_deltas))
03323                 return False;
03324         if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->num_deltas2))
03325                 return False;
03326 
03327         if (r_s->num_deltas2 != 0)
03328         {
03329                 if (!prs_uint32("num_deltas2 ", ps, depth, &r_s->num_deltas2))
03330                         return False;
03331 
03332                 if (r_s->ptr_deltas != 0)
03333                 {
03334                         if (UNMARSHALLING(ps)) {
03335                                 if (r_s->num_deltas) {
03336                                         r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas);
03337                                         if (r_s->hdr_deltas == NULL) {
03338                                                 DEBUG(0, ("error tallocating memory "
03339                                                         "for %d delta headers\n", 
03340                                                         r_s->num_deltas));
03341                                                 return False;
03342                                         }
03343                                 } else {
03344                                         r_s->hdr_deltas = NULL;
03345                                 }
03346                         }
03347 
03348                         for (i = 0; i < r_s->num_deltas; i++)
03349                         {
03350                                 net_io_sam_delta_hdr("", &r_s->hdr_deltas[i],
03351                                                       ps, depth);
03352                         }
03353                         
03354                         if (UNMARSHALLING(ps)) {
03355                                 if (r_s->num_deltas) {
03356                                         r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas);
03357                                         if (r_s->deltas == NULL) {
03358                                                 DEBUG(0, ("error tallocating memory "
03359                                                         "for %d deltas\n", 
03360                                                         r_s->num_deltas));
03361                                                 return False;
03362                                         }
03363                                 } else {
03364                                         r_s->deltas = NULL;
03365                                 }
03366                         }
03367 
03368                         for (i = 0; i < r_s->num_deltas; i++)
03369                         {
03370                                 if (!net_io_sam_delta_ctr(
03371                                         "",
03372                                         &r_s->deltas[i],
03373                                         r_s->hdr_deltas[i].type2,
03374                                         ps, depth))
03375                                         
03376                                         return False;
03377                         }
03378                 }
03379         }
03380 
03381         prs_align(ps);
03382         if (!prs_ntstatus("status", ps, depth, &r_s->status))
03383                 return False;
03384 
03385         return True;
03386 }
03387 
03388 /*******************************************************************
03389  Inits a NET_Q_DSR_GETDCNAME structure.
03390 ********************************************************************/
03391 
03392 void init_net_q_dsr_getdcname(NET_Q_DSR_GETDCNAME *r_t, const char *server_unc,
03393                               const char *domain_name,
03394                               struct GUID *domain_guid,
03395                               struct GUID *site_guid,
03396                               uint32_t flags)
03397 {
03398         DEBUG(5, ("init_net_q_dsr_getdcname\n"));
03399 
03400         r_t->ptr_server_unc = (server_unc != NULL);
03401         init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE);
03402 
03403         r_t->ptr_domain_name = (domain_name != NULL);
03404         init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
03405 
03406         r_t->ptr_domain_guid = (domain_guid != NULL);
03407         r_t->domain_guid = domain_guid;
03408 
03409         r_t->ptr_site_guid = (site_guid != NULL);
03410         r_t->site_guid = site_guid;
03411 
03412         r_t->flags = flags;
03413 }
03414 
03415 /*******************************************************************
03416  Inits a NET_Q_DSR_GETDCNAMEEX structure.
03417 ********************************************************************/
03418 
03419 void init_net_q_dsr_getdcnameex(NET_Q_DSR_GETDCNAMEEX *r_t, const char *server_unc,
03420                                 const char *domain_name,
03421                                 struct GUID *domain_guid,
03422                                 const char *site_name,
03423                                 uint32_t flags)
03424 {
03425         DEBUG(5, ("init_net_q_dsr_getdcnameex\n"));
03426 
03427         r_t->ptr_server_unc = (server_unc != NULL);
03428         init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE);
03429 
03430         r_t->ptr_domain_name = (domain_name != NULL);
03431         init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
03432 
03433         r_t->ptr_domain_guid = (domain_guid != NULL);
03434         r_t->domain_guid = domain_guid;
03435 
03436         r_t->ptr_site_name = (site_name != NULL);
03437         init_unistr2(&r_t->uni_site_name, site_name, UNI_STR_TERMINATE);
03438 
03439         r_t->flags = flags;
03440 }
03441 
03442 /*******************************************************************
03443  Inits a NET_Q_DSR_GETDCNAMEEX2 structure.
03444 ********************************************************************/
03445 
03446 void init_net_q_dsr_getdcnameex2(NET_Q_DSR_GETDCNAMEEX2 *r_t, const char *server_unc,
03447                                  const char *domain_name,
03448                                  const char *client_account,
03449                                  uint32 mask,
03450                                  struct GUID *domain_guid,
03451                                  const char *site_name,
03452                                  uint32_t flags)
03453 {
03454         DEBUG(5, ("init_net_q_dsr_getdcnameex2\n"));
03455 
03456         r_t->ptr_server_unc = (server_unc != NULL);
03457         init_unistr2(&r_t->uni_server_unc, server_unc, UNI_STR_TERMINATE);
03458 
03459         r_t->ptr_client_account = (client_account != NULL);
03460         init_unistr2(&r_t->uni_client_account, client_account, UNI_STR_TERMINATE);
03461 
03462         r_t->mask = mask;
03463 
03464         r_t->ptr_domain_name = (domain_name != NULL);
03465         init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
03466 
03467         r_t->ptr_domain_guid = (domain_guid != NULL);
03468         r_t->domain_guid = domain_guid;
03469 
03470         r_t->ptr_site_name = (site_name != NULL);
03471         init_unistr2(&r_t->uni_site_name, site_name, UNI_STR_TERMINATE);
03472 
03473         r_t->flags = flags;
03474 }
03475 
03476 /*******************************************************************
03477  Reads or writes an NET_Q_DSR_GETDCNAME structure.
03478 ********************************************************************/
03479 
03480 BOOL net_io_q_dsr_getdcname(const char *desc, NET_Q_DSR_GETDCNAME *r_t,
03481                             prs_struct *ps, int depth)
03482 {
03483         if (r_t == NULL)
03484                 return False;
03485 
03486         prs_debug(ps, depth, desc, "net_io_q_dsr_getdcname");
03487         depth++;
03488 
03489         if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc))
03490                 return False;
03491 
03492         if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc,
03493                             r_t->ptr_server_unc, ps, depth))
03494                 return False;
03495 
03496         if (!prs_align(ps))
03497                 return False;
03498 
03499         if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
03500                 return False;
03501 
03502         if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
03503                             r_t->ptr_domain_name, ps, depth))
03504                 return False;
03505 
03506         if (!prs_align(ps))
03507                 return False;
03508 
03509         if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid))
03510                 return False;
03511 
03512         if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) {
03513                 r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
03514                 if (r_t->domain_guid == NULL)
03515                         return False;
03516         }
03517 
03518         if ((r_t->ptr_domain_guid) &&
03519             (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth)))
03520                 return False;
03521 
03522         if (!prs_align(ps))
03523                 return False;
03524 
03525         if (!prs_uint32("ptr_site_guid", ps, depth, &r_t->ptr_site_guid))
03526                 return False;
03527 
03528         if (UNMARSHALLING(ps) && (r_t->ptr_site_guid)) {
03529                 r_t->site_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
03530                 if (r_t->site_guid == NULL)
03531                         return False;
03532         }
03533 
03534         if ((r_t->ptr_site_guid) &&
03535             (!smb_io_uuid("site_guid", r_t->site_guid, ps, depth)))
03536                 return False;
03537 
03538         if (!prs_align(ps))
03539                 return False;
03540 
03541         if (!prs_uint32("flags", ps, depth, &r_t->flags))
03542                 return False;
03543 
03544         return True;
03545 }
03546 
03547 /*******************************************************************
03548  Reads or writes an NET_Q_DSR_GETDCNAMEEX structure.
03549 ********************************************************************/
03550 
03551 BOOL net_io_q_dsr_getdcnameex(const char *desc, NET_Q_DSR_GETDCNAMEEX *r_t,
03552                               prs_struct *ps, int depth)
03553 {
03554         if (r_t == NULL)
03555                 return False;
03556 
03557         prs_debug(ps, depth, desc, "net_io_q_dsr_getdcnameex");
03558         depth++;
03559 
03560         if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc))
03561                 return False;
03562 
03563         if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc,
03564                             r_t->ptr_server_unc, ps, depth))
03565                 return False;
03566 
03567         if (!prs_align(ps))
03568                 return False;
03569 
03570         if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
03571                 return False;
03572 
03573         if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
03574                             r_t->ptr_domain_name, ps, depth))
03575                 return False;
03576 
03577         if (!prs_align(ps))
03578                 return False;
03579 
03580         if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid))
03581                 return False;
03582 
03583         if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) {
03584                 r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
03585                 if (r_t->domain_guid == NULL)
03586                         return False;
03587         }
03588 
03589         if ((r_t->ptr_domain_guid) &&
03590             (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth)))
03591                 return False;
03592 
03593         if (!prs_align(ps))
03594                 return False;
03595 
03596         if (!prs_uint32("ptr_site_name", ps, depth, &r_t->ptr_site_name))
03597                 return False;
03598 
03599         if (!smb_io_unistr2("site_name", &r_t->uni_site_name,
03600                             r_t->ptr_site_name, ps, depth))
03601                 return False;
03602 
03603         if (!prs_align(ps))
03604                 return False;
03605 
03606         if (!prs_uint32("flags", ps, depth, &r_t->flags))
03607                 return False;
03608 
03609         return True;
03610 }
03611 
03612 /*******************************************************************
03613  Reads or writes an NET_Q_DSR_GETDCNAMEEX2 structure.
03614 ********************************************************************/
03615 
03616 BOOL net_io_q_dsr_getdcnameex2(const char *desc, NET_Q_DSR_GETDCNAMEEX2 *r_t,
03617                                prs_struct *ps, int depth)
03618 {
03619         if (r_t == NULL)
03620                 return False;
03621 
03622         prs_debug(ps, depth, desc, "net_io_q_dsr_getdcnameex2");
03623         depth++;
03624 
03625         if (!prs_uint32("ptr_server_unc", ps, depth, &r_t->ptr_server_unc))
03626                 return False;
03627 
03628         if (!smb_io_unistr2("server_unc", &r_t->uni_server_unc,
03629                             r_t->ptr_server_unc, ps, depth))
03630                 return False;
03631 
03632         if (!prs_align(ps))
03633                 return False;
03634 
03635         if (!prs_uint32("ptr_client_account", ps, depth, &r_t->ptr_client_account))
03636                 return False;
03637 
03638         if (!smb_io_unistr2("client_account", &r_t->uni_client_account,
03639                             r_t->ptr_client_account, ps, depth))
03640                 return False;
03641 
03642         if (!prs_align(ps))
03643                 return False;
03644 
03645         if (!prs_uint32("mask", ps, depth, &r_t->mask))
03646                 return False;
03647 
03648         if (!prs_align(ps))
03649                 return False;
03650 
03651         if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
03652                 return False;
03653 
03654         if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
03655                             r_t->ptr_domain_name, ps, depth))
03656                 return False;
03657 
03658         if (!prs_align(ps))
03659                 return False;
03660 
03661         if (!prs_uint32("ptr_domain_guid", ps, depth, &r_t->ptr_domain_guid))
03662                 return False;
03663 
03664         if (UNMARSHALLING(ps) && (r_t->ptr_domain_guid)) {
03665                 r_t->domain_guid = PRS_ALLOC_MEM(ps, struct GUID, 1);
03666                 if (r_t->domain_guid == NULL)
03667                         return False;
03668         }
03669 
03670         if ((r_t->ptr_domain_guid) &&
03671             (!smb_io_uuid("domain_guid", r_t->domain_guid, ps, depth)))
03672                 return False;
03673 
03674         if (!prs_align(ps))
03675                 return False;
03676 
03677         if (!prs_uint32("ptr_site_name", ps, depth, &r_t->ptr_site_name))
03678                 return False;
03679 
03680         if (!smb_io_unistr2("site_name", &r_t->uni_site_name,
03681                             r_t->ptr_site_name, ps, depth))
03682                 return False;
03683 
03684         if (!prs_align(ps))
03685                 return False;
03686 
03687         if (!prs_uint32("flags", ps, depth, &r_t->flags))
03688                 return False;
03689 
03690         return True;
03691 }
03692 
03693 
03694 
03695 /*******************************************************************
03696  Inits a NET_R_DSR_GETDCNAME structure.
03697 ********************************************************************/
03698 void init_net_r_dsr_getdcname(NET_R_DSR_GETDCNAME *r_t, const char *dc_unc,
03699                               const char *dc_address, int32 dc_address_type,
03700                               struct GUID domain_guid, const char *domain_name,
03701                               const char *forest_name, uint32 dc_flags,
03702                               const char *dc_site_name,
03703                               const char *client_site_name)
03704 {
03705         DEBUG(5, ("init_net_q_dsr_getdcname\n"));
03706 
03707         r_t->ptr_dc_unc = (dc_unc != NULL);
03708         init_unistr2(&r_t->uni_dc_unc, dc_unc, UNI_STR_TERMINATE);
03709 
03710         r_t->ptr_dc_address = (dc_address != NULL);
03711         init_unistr2(&r_t->uni_dc_address, dc_address, UNI_STR_TERMINATE);
03712 
03713         r_t->dc_address_type = dc_address_type;
03714         r_t->domain_guid = domain_guid;
03715 
03716         r_t->ptr_domain_name = (domain_name != NULL);
03717         init_unistr2(&r_t->uni_domain_name, domain_name, UNI_STR_TERMINATE);
03718 
03719         r_t->ptr_forest_name = (forest_name != NULL);
03720         init_unistr2(&r_t->uni_forest_name, forest_name, UNI_STR_TERMINATE);
03721 
03722         r_t->dc_flags = dc_flags;
03723 
03724         r_t->ptr_dc_site_name = (dc_site_name != NULL);
03725         init_unistr2(&r_t->uni_dc_site_name, dc_site_name, UNI_STR_TERMINATE);
03726 
03727         r_t->ptr_client_site_name = (client_site_name != NULL);
03728         init_unistr2(&r_t->uni_client_site_name, client_site_name,
03729                      UNI_STR_TERMINATE);
03730 }
03731 
03732 /*******************************************************************
03733  Reads or writes an NET_R_DSR_GETDCNAME structure.
03734 ********************************************************************/
03735 
03736 BOOL net_io_r_dsr_getdcname(const char *desc, NET_R_DSR_GETDCNAME *r_t,
03737                             prs_struct *ps, int depth)
03738 {
03739         uint32 info_ptr = 1;
03740 
03741         if (r_t == NULL)
03742                 return False;
03743 
03744         prs_debug(ps, depth, desc, "net_io_r_dsr_getdcname");
03745         depth++;
03746 
03747         /* The reply contains *just* an info struct, this is the ptr to it */
03748         if (!prs_uint32("info_ptr", ps, depth, &info_ptr))
03749                 return False;
03750 
03751         if (info_ptr == 0)
03752                 return False;
03753 
03754         if (!prs_uint32("ptr_dc_unc", ps, depth, &r_t->ptr_dc_unc))
03755                 return False;
03756 
03757         if (!prs_uint32("ptr_dc_address", ps, depth, &r_t->ptr_dc_address))
03758                 return False;
03759 
03760         if (!prs_int32("dc_address_type", ps, depth, &r_t->dc_address_type))
03761                 return False;
03762 
03763         if (!smb_io_uuid("domain_guid", &r_t->domain_guid, ps, depth))
03764                 return False;
03765 
03766         if (!prs_uint32("ptr_domain_name", ps, depth, &r_t->ptr_domain_name))
03767                 return False;
03768 
03769         if (!prs_uint32("ptr_forest_name", ps, depth, &r_t->ptr_forest_name))
03770                 return False;
03771 
03772         if (!prs_uint32("dc_flags", ps, depth, &r_t->dc_flags))
03773                 return False;
03774 
03775         if (!prs_uint32("ptr_dc_site_name", ps, depth, &r_t->ptr_dc_site_name))
03776                 return False;
03777 
03778         if (!prs_uint32("ptr_client_site_name", ps, depth,
03779                         &r_t->ptr_client_site_name))
03780                 return False;
03781 
03782         if (!prs_align(ps))
03783                 return False;
03784 
03785         if (!smb_io_unistr2("dc_unc", &r_t->uni_dc_unc,
03786                             r_t->ptr_dc_unc, ps, depth))
03787                 return False;
03788 
03789         if (!prs_align(ps))
03790                 return False;
03791 
03792         if (!smb_io_unistr2("dc_address", &r_t->uni_dc_address,
03793                             r_t->ptr_dc_address, ps, depth))
03794                 return False;
03795 
03796         if (!prs_align(ps))
03797                 return False;
03798 
03799         if (!smb_io_unistr2("domain_name", &r_t->uni_domain_name,
03800                             r_t->ptr_domain_name, ps, depth))
03801                 return False;
03802 
03803         if (!prs_align(ps))
03804                 return False;
03805 
03806         if (!smb_io_unistr2("forest_name", &r_t->uni_forest_name,
03807                             r_t->ptr_forest_name, ps, depth))
03808                 return False;
03809 
03810         if (!prs_align(ps))
03811                 return False;
03812 
03813         if (!smb_io_unistr2("dc_site_name", &r_t->uni_dc_site_name,
03814                             r_t->ptr_dc_site_name, ps, depth))
03815                 return False;
03816 
03817         if (!prs_align(ps))
03818                 return False;
03819 
03820         if (!smb_io_unistr2("client_site_name", &r_t->uni_client_site_name,
03821                             r_t->ptr_client_site_name, ps, depth))
03822                 return False;
03823 
03824         if (!prs_align(ps))
03825                 return False;
03826 
03827         if (!prs_werror("result", ps, depth, &r_t->result))
03828                 return False;
03829 
03830         return True;
03831 }
03832 
03833 /*******************************************************************
03834  Inits a NET_Q_DSR_GETSITENAME structure.
03835 ********************************************************************/
03836 
03837 void init_net_q_dsr_getsitename(NET_Q_DSR_GETSITENAME *r_t, const char *computer_name)
03838 {
03839         DEBUG(5, ("init_net_q_dsr_getsitename\n"));
03840 
03841         r_t->ptr_computer_name = (computer_name != NULL);
03842         init_unistr2(&r_t->uni_computer_name, computer_name, UNI_STR_TERMINATE);
03843 }
03844 
03845 /*******************************************************************
03846  Reads or writes an NET_Q_DSR_GETSITENAME structure.
03847 ********************************************************************/
03848 
03849 BOOL net_io_q_dsr_getsitename(const char *desc, NET_Q_DSR_GETSITENAME *r_t,
03850                               prs_struct *ps, int depth)
03851 {
03852         if (r_t == NULL)
03853                 return False;
03854 
03855         prs_debug(ps, depth, desc, "net_io_q_dsr_getsitename");
03856         depth++;
03857 
03858         if (!prs_uint32("ptr_computer_name", ps, depth, &r_t->ptr_computer_name))
03859                 return False;
03860 
03861         if (!smb_io_unistr2("computer_name", &r_t->uni_computer_name,
03862                             r_t->ptr_computer_name, ps, depth))
03863                 return False;
03864 
03865         if (!prs_align(ps))
03866                 return False;
03867 
03868         return True;
03869 }
03870 
03871 /*******************************************************************
03872  Reads or writes an NET_R_DSR_GETSITENAME structure.
03873 ********************************************************************/
03874 
03875 BOOL net_io_r_dsr_getsitename(const char *desc, NET_R_DSR_GETSITENAME *r_t,
03876                               prs_struct *ps, int depth)
03877 {
03878         if (r_t == NULL)
03879                 return False;
03880 
03881         prs_debug(ps, depth, desc, "net_io_r_dsr_getsitename");
03882         depth++;
03883 
03884         if (!prs_uint32("ptr_site_name", ps, depth, &r_t->ptr_site_name))
03885                 return False;
03886 
03887         if (!prs_align(ps))
03888                 return False;
03889 
03890         if (!smb_io_unistr2("site_name", &r_t->uni_site_name,
03891                             r_t->ptr_site_name, ps, depth))
03892                 return False;
03893 
03894         if (!prs_align(ps))
03895                 return False;
03896 
03897         if (!prs_werror("result", ps, depth, &r_t->result))
03898                 return False;
03899 
03900         return True;
03901 }
03902 
03903 

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