2 Samba Unix/Linux SMB client library
3 More client RAP (SMB Remote Procedure Calls) functions
4 Copyright (C) 2001 Steve French (sfrench@us.ibm.com)
5 Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com)
6 Copyright (C) 2007 Jeremy Allison. jra@samba.org
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 /*****************************************************/
24 /* Additional RAP functionality */
26 /* RAP is the original SMB RPC, documented */
27 /* by Microsoft and X/Open in the 1990s and */
28 /* supported by most SMB/CIFS servers although */
29 /* it is unlikely that any one implementation */
30 /* supports all RAP command codes since some */
31 /* are quite obsolete and a few are specific */
32 /* to a particular network operating system */
34 /* Although it has largely been replaced */
35 /* for complex remote administration and management */
36 /* (of servers) by the relatively newer */
37 /* DCE/RPC based remote API (which better handles */
38 /* large >64K data structures), there are many */
39 /* important administrative and resource location */
40 /* tasks and user tasks (e.g. password change) */
41 /* that are performed via RAP. */
43 /* Although a few of the RAP calls are implemented */
44 /* in the Samba client library already (clirap.c) */
45 /* the new ones are in clirap2.c for easy patching */
46 /* and integration and a corresponding header */
47 /* file, rap.h, has been created. */
49 /* This is based on data from the CIFS spec */
50 /* and the LAN Server and LAN Manager */
51 /* Programming Reference books and published */
52 /* RAP document and CIFS forum postings and */
53 /* lots of trial and error */
55 /* Function names changed from API_ (as they are */
56 /* in the CIFS specification) to RAP_ in order */
57 /* to avoid confusion with other API calls */
58 /* sent via DCE RPC */
60 /*****************************************************/
62 /*****************************************************/
64 /* cifsrap.c already includes support for: */
66 /* WshareEnum ( API number 0, level 1) */
67 /* NetServerEnum2 (API num 104, level 1) */
68 /* WWkstaUserLogon (132) */
69 /* SamOEMchgPasswordUser2_P (214) */
71 /* cifsprint.c already includes support for: */
73 /* WPrintJobEnum (API num 76, level 2) */
74 /* WPrintJobDel (API num 81) */
76 /*****************************************************/
79 #include "libsmb/libsmb.h"
80 #include "../librpc/gen_ndr/rap.h"
81 #include "../librpc/gen_ndr/svcctl.h"
83 #include "../libcli/smb/smbXcli_base.h"
88 #define PUTBYTE(p,b) do {SCVAL(p,0,b); p++;} while(0)
90 #define GETBYTE(p,b,endp) \
98 #define PUTWORD(p,w) do {SSVAL(p,0,w); p += WORDSIZE;} while(0)
100 #define GETWORD(p,w,endp) \
102 if (p+WORDSIZE < endp) {\
108 #define PUTDWORD(p,d) do {SIVAL(p,0,d); p += DWORDSIZE;} while(0)
110 #define GETDWORD(p,d,endp) \
112 if (p+DWORDSIZE < endp) {\
118 #define GETRES(p,endp) ((p && p+2 < endp) ? SVAL(p,0) : -1)
121 * Skip past some strings in a buffer - old version - no checks.
124 static char *push_skip_string(char *buf
)
126 buf
+= strlen(buf
) + 1;
130 /* put string s at p with max len n and increment p past string */
131 #define PUTSTRING(p,s,n) \
133 push_ascii(p,s?s:"",n?n:256,STR_TERMINATE);\
134 p = push_skip_string(p);\
137 /* put string s and p, using fixed len l, and increment p by l */
138 #define PUTSTRINGF(p,s,l) \
140 push_ascii(p,s?s:"",l,STR_TERMINATE);\
144 /* put string pointer at p, supplying offset o from rdata r, store */
145 /* dword offset at p, increment p by 4 and o by length of s. This */
146 /* means on the first call, you must calc the offset yourself! */
148 #define PUTSTRINGP(p,s,r,o) \
151 push_ascii(r+o,s,strlen(s)+1,STR_TERMINATE);\
159 /* get asciiz string dest from src, return increment past string */
161 static size_t rap_getstring(TALLOC_CTX
*ctx
, char *src
, char **dest
, const char *endp
)
167 for (p1
= src
, len
= 0; *p1
&& p1
< endp
; len
++)
172 pull_string_talloc(ctx
,src
,0,dest
,src
,len
,STR_ASCII
);
176 /* get fixed length l string dest from src, return increment for src */
178 static size_t rap_getstringf(char *src
, char *dest
, size_t l
, size_t dlen
, char *endp
)
186 for (p1
= src
, len
= 0; *p1
&& p1
< endp
; len
++) {
196 pull_ascii(dest
,src
,len
,len
,STR_ASCII
);
201 /* get string dest from offset (obtained at p) from rdata r - converter c */
202 static size_t rap_getstringp(TALLOC_CTX
*ctx
, char *p
, char **dest
, char *r
, uint16_t c
, char *endp
)
210 GETDWORD(p
,off
,endp
);
211 off
&= 0x0000FFFF; /* mask the obsolete segment number from the offset */
214 if (r
+off
> endp
|| r
+off
< r
) {
220 for (p1
= src
, len
= 0; *p1
&& p1
< endp
; len
++) {
227 pull_string_talloc(ctx
,src
,0,dest
,src
,len
,STR_ASCII
);
231 static char *make_header(char *param
, uint16_t apinum
, const char *reqfmt
, const char *datafmt
)
233 PUTWORD(param
,apinum
);
235 PUTSTRING(param
,reqfmt
,0);
240 PUTSTRING(param
,datafmt
,0);
247 /****************************************************************************
248 call a NetGroupDelete - delete user group from remote server
249 ****************************************************************************/
251 int cli_NetGroupDelete(struct cli_state
*cli
, const char *group_name
)
256 unsigned int rdrcnt
,rprcnt
;
258 char param
[WORDSIZE
/* api number */
259 +sizeof(RAP_NetGroupDel_REQ
) /* parm string */
260 +1 /* no ret string */
261 +RAP_GROUPNAME_LEN
/* group to del */
262 +WORDSIZE
]; /* reserved word */
264 /* now send a SMBtrans command with api GroupDel */
265 p
= make_header(param
, RAP_WGroupDel
, RAP_NetGroupDel_REQ
, NULL
);
266 PUTSTRING(p
, group_name
, RAP_GROUPNAME_LEN
);
267 PUTWORD(p
,0); /* reserved word MBZ on input */
270 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
271 NULL
, 0, 200, /* data, length, maxlen */
272 &rparam
, &rprcnt
, /* return params, length */
273 &rdata
, &rdrcnt
)) /* return data, length */
275 char *endp
= rparam
+ rprcnt
;
276 res
= GETRES(rparam
,endp
);
280 } else if ((res
== 5) || (res
== 65)) {
281 DEBUG(1, ("Access Denied\n"));
282 } else if (res
== 2220) {
283 DEBUG (1, ("Group does not exist\n"));
285 DEBUG(4,("NetGroupDelete res=%d\n", res
));
289 DEBUG(4,("NetGroupDelete failed\n"));
298 /****************************************************************************
299 call a NetGroupAdd - add user group to remote server
300 ****************************************************************************/
302 int cli_NetGroupAdd(struct cli_state
*cli
, struct rap_group_info_1
*grinfo
)
307 unsigned int rdrcnt
,rprcnt
;
309 char param
[WORDSIZE
/* api number */
310 +sizeof(RAP_NetGroupAdd_REQ
) /* req string */
311 +sizeof(RAP_GROUP_INFO_L1
) /* return string */
312 +WORDSIZE
/* info level */
313 +WORDSIZE
]; /* reserved word */
315 /* offset into data of free format strings. Will be updated */
316 /* by PUTSTRINGP macro and end up with total data length. */
317 int soffset
= RAP_GROUPNAME_LEN
+ 1 + DWORDSIZE
;
322 data_size
= MAX(soffset
+ strlen(grinfo
->comment
) + 1, 1024);
324 data
= SMB_MALLOC_ARRAY(char, data_size
);
326 DEBUG (1, ("Malloc fail\n"));
330 /* now send a SMBtrans command with api WGroupAdd */
332 p
= make_header(param
, RAP_WGroupAdd
,
333 RAP_NetGroupAdd_REQ
, RAP_GROUP_INFO_L1
);
334 PUTWORD(p
, 1); /* info level */
335 PUTWORD(p
, 0); /* reserved word 0 */
338 PUTSTRINGF(p
, (const char *)grinfo
->group_name
, RAP_GROUPNAME_LEN
);
339 PUTBYTE(p
, 0); /* pad byte 0 */
340 PUTSTRINGP(p
, grinfo
->comment
, data
, soffset
);
343 param
, sizeof(param
), 1024, /* Param, length, maxlen */
344 data
, soffset
, data_size
, /* data, length, maxlen */
345 &rparam
, &rprcnt
, /* return params, length */
346 &rdata
, &rdrcnt
)) /* return data, length */
348 char *endp
= rparam
+ rprcnt
;
349 res
= GETRES(rparam
, endp
);
353 } else if ((res
== 5) || (res
== 65)) {
354 DEBUG(1, ("Access Denied\n"));
355 } else if (res
== 2223) {
356 DEBUG (1, ("Group already exists\n"));
358 DEBUG(4,("NetGroupAdd res=%d\n", res
));
362 DEBUG(4,("NetGroupAdd failed\n"));
372 /****************************************************************************
373 Call a NetGroupEnum - try and list user groups on a different host.
374 ****************************************************************************/
376 int cli_RNetGroupEnum(struct cli_state
*cli
, void (*fn
)(const char *, const char *, void *), void *state
)
378 char param
[WORDSIZE
/* api number */
379 +sizeof(RAP_NetGroupEnum_REQ
) /* parm string */
380 +sizeof(RAP_GROUP_INFO_L1
) /* return string */
381 +WORDSIZE
/* info level */
382 +WORDSIZE
]; /* buffer size */
386 unsigned int rprcnt
, rdrcnt
;
389 memset(param
, '\0', sizeof(param
));
390 p
= make_header(param
, RAP_WGroupEnum
,
391 RAP_NetGroupEnum_REQ
, RAP_GROUP_INFO_L1
);
392 PUTWORD(p
,1); /* Info level 1 */ /* add level 0 */
393 PUTWORD(p
,0xFFE0); /* Return buffer size */
396 param
, PTR_DIFF(p
,param
),8,
397 NULL
, 0, 0xFFE0 /* data area size */,
400 char *endp
= rparam
+ rdrcnt
;
402 res
= GETRES(rparam
, endp
);
403 cli
->rap_error
= res
;
404 if(cli
->rap_error
== 234) {
405 DEBUG(1,("Not all group names were returned (such as those longer than 21 characters)\n"));
406 } else if (cli
->rap_error
!= 0) {
407 DEBUG(1,("NetGroupEnum gave error %d\n", cli
->rap_error
));
412 DEBUG(4,("NetGroupEnum no data returned\n"));
416 if (res
== 0 || res
== ERRmoredata
) {
417 char *endp
= rparam
+ rprcnt
;
418 int i
, converter
= 0, count
= 0;
419 TALLOC_CTX
*frame
= talloc_stackframe();
421 p
= rparam
+ WORDSIZE
; /* skip result */
422 GETWORD(p
, converter
, endp
);
423 GETWORD(p
, count
, endp
);
425 endp
= rdata
+ rdrcnt
;
426 for (i
=0,p
=rdata
; i
<count
&& p
< endp
;i
++) {
427 char *comment
= NULL
;
428 char groupname
[RAP_GROUPNAME_LEN
];
430 p
+= rap_getstringf(p
,
436 p
+= rap_getstringp(frame
,
443 if (!comment
|| !groupname
[0]) {
447 fn(groupname
, comment
, cli
);
451 DEBUG(4,("NetGroupEnum res=%d\n", res
));
462 int cli_RNetGroupEnum0(struct cli_state
*cli
,
463 void (*fn
)(const char *, void *),
466 char param
[WORDSIZE
/* api number */
467 +sizeof(RAP_NetGroupEnum_REQ
) /* parm string */
468 +sizeof(RAP_GROUP_INFO_L0
) /* return string */
469 +WORDSIZE
/* info level */
470 +WORDSIZE
]; /* buffer size */
474 unsigned int rprcnt
, rdrcnt
;
477 memset(param
, '\0', sizeof(param
));
478 p
= make_header(param
, RAP_WGroupEnum
,
479 RAP_NetGroupEnum_REQ
, RAP_GROUP_INFO_L0
);
480 PUTWORD(p
,0); /* Info level 0 */ /* Hmmm. I *very* much suspect this
481 is the resume count, at least
482 that's what smbd believes... */
483 PUTWORD(p
,0xFFE0); /* Return buffer size */
486 param
, PTR_DIFF(p
,param
),8,
487 NULL
, 0, 0xFFE0 /* data area size */,
490 char *endp
= rparam
+rprcnt
;
491 res
= GETRES(rparam
,endp
);
492 cli
->rap_error
= res
;
493 if(cli
->rap_error
== 234) {
494 DEBUG(1,("Not all group names were returned (such as those longer than 21 characters)\n"));
495 } else if (cli
->rap_error
!= 0) {
496 DEBUG(1,("NetGroupEnum gave error %d\n", cli
->rap_error
));
501 DEBUG(4,("NetGroupEnum no data returned\n"));
505 if (res
== 0 || res
== ERRmoredata
) {
506 char *endp
= rparam
+ rprcnt
;
509 p
= rparam
+ WORDSIZE
+ WORDSIZE
; /* skip result and converter */
510 GETWORD(p
, count
, endp
);
512 endp
= rdata
+ rdrcnt
;
513 for (i
=0,p
=rdata
; i
<count
&& p
< endp
;i
++) {
514 char groupname
[RAP_GROUPNAME_LEN
];
516 p
+= rap_getstringf(p
,
526 DEBUG(4,("NetGroupEnum res=%d\n", res
));
537 int cli_NetGroupDelUser(struct cli_state
* cli
, const char *group_name
, const char *user_name
)
542 unsigned int rdrcnt
,rprcnt
;
544 char param
[WORDSIZE
/* api number */
545 +sizeof(RAP_NetGroupDelUser_REQ
) /* parm string */
546 +1 /* no ret string */
547 +RAP_GROUPNAME_LEN
/* group name */
548 +RAP_USERNAME_LEN
]; /* user to del */
550 /* now send a SMBtrans command with api GroupMemberAdd */
551 p
= make_header(param
, RAP_WGroupDelUser
, RAP_NetGroupDelUser_REQ
, NULL
);
552 PUTSTRING(p
,group_name
,RAP_GROUPNAME_LEN
);
553 PUTSTRING(p
,user_name
,RAP_USERNAME_LEN
);
556 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
557 NULL
, 0, 200, /* data, length, maxlen */
558 &rparam
, &rprcnt
, /* return params, length */
559 &rdata
, &rdrcnt
)) /* return data, length */
561 char *endp
= rparam
+ rprcnt
;
562 res
= GETRES(rparam
,endp
);
569 DEBUG(1, ("Access Denied\n"));
572 DEBUG(1, ("Not supported by server\n"));
575 DEBUG(1, ("Group does not exist\n"));
578 DEBUG(1, ("User does not exist\n"));
581 DEBUG(1, ("User is not in group\n"));
584 DEBUG(4,("NetGroupDelUser res=%d\n", res
));
588 DEBUG(4,("NetGroupDelUser failed\n"));
597 int cli_NetGroupAddUser(struct cli_state
* cli
, const char *group_name
, const char *user_name
)
602 unsigned int rdrcnt
,rprcnt
;
604 char param
[WORDSIZE
/* api number */
605 +sizeof(RAP_NetGroupAddUser_REQ
) /* parm string */
606 +1 /* no ret string */
607 +RAP_GROUPNAME_LEN
/* group name */
608 +RAP_USERNAME_LEN
]; /* user to add */
610 /* now send a SMBtrans command with api GroupMemberAdd */
611 p
= make_header(param
, RAP_WGroupAddUser
, RAP_NetGroupAddUser_REQ
, NULL
);
612 PUTSTRING(p
,group_name
,RAP_GROUPNAME_LEN
);
613 PUTSTRING(p
,user_name
,RAP_USERNAME_LEN
);
616 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
617 NULL
, 0, 200, /* data, length, maxlen */
618 &rparam
, &rprcnt
, /* return params, length */
619 &rdata
, &rdrcnt
)) /* return data, length */
621 char *endp
= rparam
+ rprcnt
;
622 res
= GETRES(rparam
,endp
);
629 DEBUG(1, ("Access Denied\n"));
632 DEBUG(1, ("Not supported by server\n"));
635 DEBUG(1, ("Group does not exist\n"));
638 DEBUG(1, ("User does not exist\n"));
641 DEBUG(4,("NetGroupAddUser res=%d\n", res
));
645 DEBUG(4,("NetGroupAddUser failed\n"));
655 int cli_NetGroupGetUsers(struct cli_state
* cli
, const char *group_name
, void (*fn
)(const char *, void *), void *state
)
660 unsigned int rdrcnt
,rprcnt
;
662 char param
[WORDSIZE
/* api number */
663 +sizeof(RAP_NetGroupGetUsers_REQ
)/* parm string */
664 +sizeof(RAP_GROUP_USERS_INFO_0
) /* return string */
665 +RAP_GROUPNAME_LEN
/* group name */
666 +WORDSIZE
/* info level */
667 +WORDSIZE
]; /* buffer size */
669 /* now send a SMBtrans command with api GroupGetUsers */
670 p
= make_header(param
, RAP_WGroupGetUsers
,
671 RAP_NetGroupGetUsers_REQ
, RAP_GROUP_USERS_INFO_0
);
672 PUTSTRING(p
,group_name
,RAP_GROUPNAME_LEN
-1);
673 PUTWORD(p
,0); /* info level 0 */
674 PUTWORD(p
,0xFFE0); /* return buffer size */
677 param
, PTR_DIFF(p
,param
),PTR_DIFF(p
,param
),
678 NULL
, 0, CLI_BUFFER_SIZE
,
681 char *endp
= rparam
+ rprcnt
;
682 res
= GETRES(rparam
,endp
);
683 cli
->rap_error
= res
;
685 DEBUG(1,("NetGroupGetUsers gave error %d\n", res
));
690 DEBUG(4,("NetGroupGetUsers no data returned\n"));
694 if (res
== 0 || res
== ERRmoredata
) {
695 char *endp
= rparam
+ rprcnt
;
697 char username
[RAP_USERNAME_LEN
];
699 p
= rparam
+ WORDSIZE
+ WORDSIZE
;
700 GETWORD(p
, count
, endp
);
702 endp
= rdata
+ rdrcnt
;
703 for (i
=0,p
=rdata
; i
<count
&& p
< endp
; i
++) {
704 p
+= rap_getstringf(p
,
714 DEBUG(4,("NetGroupGetUsers res=%d\n", res
));
724 int cli_NetUserGetGroups(struct cli_state
* cli
, const char *user_name
, void (*fn
)(const char *, void *), void *state
)
729 unsigned int rdrcnt
,rprcnt
;
731 char param
[WORDSIZE
/* api number */
732 +sizeof(RAP_NetUserGetGroups_REQ
)/* parm string */
733 +sizeof(RAP_GROUP_USERS_INFO_0
) /* return string */
734 +RAP_USERNAME_LEN
/* user name */
735 +WORDSIZE
/* info level */
736 +WORDSIZE
]; /* buffer size */
738 /* now send a SMBtrans command with api GroupGetUsers */
739 p
= make_header(param
, RAP_WUserGetGroups
,
740 RAP_NetUserGetGroups_REQ
, RAP_GROUP_USERS_INFO_0
);
741 PUTSTRING(p
,user_name
,RAP_USERNAME_LEN
-1);
742 PUTWORD(p
,0); /* info level 0 */
743 PUTWORD(p
,0xFFE0); /* return buffer size */
746 param
, PTR_DIFF(p
,param
),PTR_DIFF(p
,param
),
747 NULL
, 0, CLI_BUFFER_SIZE
,
750 char *endp
= rparam
+ rprcnt
;
751 res
= GETRES(rparam
,endp
);
752 cli
->rap_error
= res
;
754 DEBUG(1,("NetUserGetGroups gave error %d\n", res
));
759 DEBUG(4,("NetUserGetGroups no data returned\n"));
763 if (res
== 0 || res
== ERRmoredata
) {
764 char *endp
= rparam
+ rprcnt
;
766 char groupname
[RAP_GROUPNAME_LEN
];
768 p
= rparam
+ WORDSIZE
+ WORDSIZE
;
769 GETWORD(p
, count
, endp
);
771 endp
= rdata
+ rdrcnt
;
772 for (i
=0,p
=rdata
; i
<count
&& p
< endp
; i
++) {
773 p
+= rap_getstringf(p
,
779 fn(groupname
, state
);
783 DEBUG(4,("NetUserGetGroups res=%d\n", res
));
793 /****************************************************************************
794 Call a NetUserDelete - delete user from remote server.
795 ****************************************************************************/
797 int cli_NetUserDelete(struct cli_state
*cli
, const char * user_name
)
802 unsigned int rdrcnt
,rprcnt
;
804 char param
[WORDSIZE
/* api number */
805 +sizeof(RAP_NetGroupDel_REQ
) /* parm string */
806 +1 /* no ret string */
807 +RAP_USERNAME_LEN
/* user to del */
808 +WORDSIZE
]; /* reserved word */
810 /* now send a SMBtrans command with api UserDel */
811 p
= make_header(param
, RAP_WUserDel
, RAP_NetGroupDel_REQ
, NULL
);
812 PUTSTRING(p
, user_name
, RAP_USERNAME_LEN
);
813 PUTWORD(p
,0); /* reserved word MBZ on input */
816 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
817 NULL
, 0, 200, /* data, length, maxlen */
818 &rparam
, &rprcnt
, /* return params, length */
819 &rdata
, &rdrcnt
)) /* return data, length */
821 char *endp
= rparam
+ rprcnt
;
822 res
= GETRES(rparam
,endp
);
826 } else if ((res
== 5) || (res
== 65)) {
827 DEBUG(1, ("Access Denied\n"));
828 } else if (res
== 2221) {
829 DEBUG (1, ("User does not exist\n"));
831 DEBUG(4,("NetUserDelete res=%d\n", res
));
835 DEBUG(4,("NetUserDelete failed\n"));
844 /****************************************************************************
845 Call a NetUserAdd - add user to remote server.
846 ****************************************************************************/
848 int cli_NetUserAdd(struct cli_state
*cli
, struct rap_user_info_1
* userinfo
)
853 unsigned int rdrcnt
,rprcnt
;
855 char param
[WORDSIZE
/* api number */
856 +sizeof(RAP_NetUserAdd2_REQ
) /* req string */
857 +sizeof(RAP_USER_INFO_L1
) /* data string */
858 +WORDSIZE
/* info level */
859 +WORDSIZE
/* buffer length */
860 +WORDSIZE
]; /* reserved */
863 /* offset into data of free format strings. Will be updated */
864 /* by PUTSTRINGP macro and end up with total data length. */
865 int soffset
=RAP_USERNAME_LEN
+1 /* user name + pad */
866 + RAP_UPASSWD_LEN
/* password */
867 + DWORDSIZE
/* password age */
868 + WORDSIZE
/* privilege */
869 + DWORDSIZE
/* home dir ptr */
870 + DWORDSIZE
/* comment ptr */
871 + WORDSIZE
/* flags */
872 + DWORDSIZE
; /* login script ptr*/
874 /* now send a SMBtrans command with api NetUserAdd */
875 p
= make_header(param
, RAP_WUserAdd2
,
876 RAP_NetUserAdd2_REQ
, RAP_USER_INFO_L1
);
878 PUTWORD(p
, 1); /* info level */
879 PUTWORD(p
, 0); /* pwencrypt */
880 PUTWORD(p
, MIN(strlen((const char *)userinfo
->passwrd
),
884 memset(data
, '\0', soffset
);
886 PUTSTRINGF(p
, (const char *)userinfo
->user_name
, RAP_USERNAME_LEN
);
887 PUTBYTE(p
, 0); /* pad byte 0 */
888 PUTSTRINGF(p
, (const char *)userinfo
->passwrd
, RAP_UPASSWD_LEN
);
889 PUTDWORD(p
, 0); /* pw age - n.a. on user add */
890 PUTWORD(p
, userinfo
->priv
);
891 PUTSTRINGP(p
, userinfo
->home_dir
, data
, soffset
);
892 PUTSTRINGP(p
, userinfo
->comment
, data
, soffset
);
893 PUTWORD(p
, userinfo
->userflags
);
894 PUTSTRINGP(p
, userinfo
->logon_script
, data
, soffset
);
897 param
, sizeof(param
), 1024, /* Param, length, maxlen */
898 data
, soffset
, sizeof(data
), /* data, length, maxlen */
899 &rparam
, &rprcnt
, /* return params, length */
900 &rdata
, &rdrcnt
)) /* return data, length */
902 char *endp
= rparam
+ rprcnt
;
903 res
= GETRES(rparam
, endp
);
907 } else if ((res
== 5) || (res
== 65)) {
908 DEBUG(1, ("Access Denied\n"));
909 } else if (res
== 2224) {
910 DEBUG (1, ("User already exists\n"));
912 DEBUG(4,("NetUserAdd res=%d\n", res
));
916 DEBUG(4,("NetUserAdd failed\n"));
925 /****************************************************************************
926 call a NetUserEnum - try and list users on a different host
927 ****************************************************************************/
929 int cli_RNetUserEnum(struct cli_state
*cli
, void (*fn
)(const char *, const char *, const char *, const char *, void *), void *state
)
931 char param
[WORDSIZE
/* api number */
932 +sizeof(RAP_NetUserEnum_REQ
) /* parm string */
933 +sizeof(RAP_USER_INFO_L1
) /* return string */
934 +WORDSIZE
/* info level */
935 +WORDSIZE
]; /* buffer size */
939 unsigned int rprcnt
, rdrcnt
;
942 memset(param
, '\0', sizeof(param
));
943 p
= make_header(param
, RAP_WUserEnum
,
944 RAP_NetUserEnum_REQ
, RAP_USER_INFO_L1
);
945 PUTWORD(p
,1); /* Info level 1 */
946 PUTWORD(p
,0xFF00); /* Return buffer size */
948 /* BB Fix handling of large numbers of users to be returned */
950 param
, PTR_DIFF(p
,param
),8,
951 NULL
, 0, CLI_BUFFER_SIZE
,
954 char *endp
= rparam
+ rprcnt
;
955 res
= GETRES(rparam
,endp
);
956 cli
->rap_error
= res
;
957 if (cli
->rap_error
!= 0) {
958 DEBUG(1,("NetUserEnum gave error %d\n", cli
->rap_error
));
963 DEBUG(4,("NetUserEnum no data returned\n"));
967 if (res
== 0 || res
== ERRmoredata
) {
968 int i
, converter
= 0, count
= 0;
969 char username
[RAP_USERNAME_LEN
];
970 char userpw
[RAP_UPASSWD_LEN
];
971 char *endp
= rparam
+ rprcnt
;
972 char *comment
, *homedir
, *logonscript
;
973 TALLOC_CTX
*frame
= talloc_stackframe();
975 p
= rparam
+ WORDSIZE
; /* skip result */
976 GETWORD(p
, converter
, endp
);
977 GETWORD(p
, count
, endp
);
979 endp
= rdata
+ rdrcnt
;
980 for (i
=0,p
=rdata
;i
<count
&& p
< endp
;i
++) {
981 p
+= rap_getstringf(p
,
987 p
+= rap_getstringf(p
,
992 p
+= DWORDSIZE
; /* skip password age */
993 p
+= WORDSIZE
; /* skip priv: 0=guest, 1=user, 2=admin */
994 p
+= rap_getstringp(frame
,
1000 p
+= rap_getstringp(frame
,
1006 p
+= WORDSIZE
; /* skip flags */
1007 p
+= rap_getstringp(frame
,
1013 if (username
[0] && comment
&&
1014 homedir
&& logonscript
) {
1024 DEBUG(4,("NetUserEnum res=%d\n", res
));
1035 int cli_RNetUserEnum0(struct cli_state
*cli
,
1036 void (*fn
)(const char *, void *),
1039 char param
[WORDSIZE
/* api number */
1040 +sizeof(RAP_NetUserEnum_REQ
) /* parm string */
1041 +sizeof(RAP_USER_INFO_L0
) /* return string */
1042 +WORDSIZE
/* info level */
1043 +WORDSIZE
]; /* buffer size */
1045 char *rparam
= NULL
;
1047 unsigned int rprcnt
, rdrcnt
;
1050 memset(param
, '\0', sizeof(param
));
1051 p
= make_header(param
, RAP_WUserEnum
,
1052 RAP_NetUserEnum_REQ
, RAP_USER_INFO_L0
);
1053 PUTWORD(p
,0); /* Info level 1 */
1054 PUTWORD(p
,0xFF00); /* Return buffer size */
1056 /* BB Fix handling of large numbers of users to be returned */
1058 param
, PTR_DIFF(p
,param
),8,
1059 NULL
, 0, CLI_BUFFER_SIZE
,
1062 char *endp
= rparam
+ rprcnt
;
1063 res
= GETRES(rparam
,endp
);
1064 cli
->rap_error
= res
;
1065 if (cli
->rap_error
!= 0) {
1066 DEBUG(1,("NetUserEnum gave error %d\n", cli
->rap_error
));
1071 DEBUG(4,("NetUserEnum no data returned\n"));
1075 if (res
== 0 || res
== ERRmoredata
) {
1077 char *endp
= rparam
+ rprcnt
;
1078 char username
[RAP_USERNAME_LEN
];
1080 p
= rparam
+ WORDSIZE
+ WORDSIZE
; /* skip result and converter */
1081 GETWORD(p
, count
, endp
);
1083 endp
= rdata
+ rdrcnt
;
1084 for (i
=0,p
=rdata
;i
<count
&& p
< endp
;i
++) {
1085 p
+= rap_getstringf(p
,
1095 DEBUG(4,("NetUserEnum res=%d\n", res
));
1106 /****************************************************************************
1107 Call a NetFileClose2 - close open file on another session to server.
1108 ****************************************************************************/
1110 int cli_NetFileClose(struct cli_state
*cli
, uint32_t file_id
)
1112 char *rparam
= NULL
;
1115 unsigned int rdrcnt
,rprcnt
;
1116 char param
[WORDSIZE
/* api number */
1117 +sizeof(RAP_WFileClose2_REQ
) /* req string */
1118 +1 /* no ret string */
1119 +DWORDSIZE
]; /* file ID */
1122 /* now send a SMBtrans command with api RNetShareEnum */
1123 p
= make_header(param
, RAP_WFileClose2
, RAP_WFileClose2_REQ
, NULL
);
1124 PUTDWORD(p
, file_id
);
1127 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
1128 NULL
, 0, 200, /* data, length, maxlen */
1129 &rparam
, &rprcnt
, /* return params, length */
1130 &rdata
, &rdrcnt
)) /* return data, length */
1132 char *endp
= rparam
+ rprcnt
;
1133 res
= GETRES(rparam
, endp
);
1137 } else if (res
== 2314){
1138 DEBUG(1, ("NetFileClose2 - attempt to close non-existent file open instance\n"));
1140 DEBUG(4,("NetFileClose2 res=%d\n", res
));
1144 DEBUG(4,("NetFileClose2 failed\n"));
1153 /****************************************************************************
1154 Call a NetFileGetInfo - get information about server file opened from other
1156 ****************************************************************************/
1158 int cli_NetFileGetInfo(struct cli_state
*cli
, uint32_t file_id
, void (*fn
)(const char *, const char *, uint16_t, uint16_t, uint32_t))
1160 char *rparam
= NULL
;
1163 unsigned int rdrcnt
,rprcnt
;
1165 char param
[WORDSIZE
/* api number */
1166 +sizeof(RAP_WFileGetInfo2_REQ
) /* req string */
1167 +sizeof(RAP_FILE_INFO_L3
) /* return string */
1168 +DWORDSIZE
/* file ID */
1169 +WORDSIZE
/* info level */
1170 +WORDSIZE
]; /* buffer size */
1172 /* now send a SMBtrans command with api RNetShareEnum */
1173 p
= make_header(param
, RAP_WFileGetInfo2
,
1174 RAP_WFileGetInfo2_REQ
, RAP_FILE_INFO_L3
);
1175 PUTDWORD(p
, file_id
);
1176 PUTWORD(p
, 3); /* info level */
1177 PUTWORD(p
, 0x1000); /* buffer size */
1179 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
1180 NULL
, 0, 0x1000, /* data, length, maxlen */
1181 &rparam
, &rprcnt
, /* return params, length */
1182 &rdata
, &rdrcnt
)) /* return data, length */
1184 char *endp
= rparam
+ rprcnt
;
1185 res
= GETRES(rparam
,endp
);
1186 if (res
== 0 || res
== ERRmoredata
) {
1187 TALLOC_CTX
*frame
= talloc_stackframe();
1188 int converter
= 0,id
= 0, perms
= 0, locks
= 0;
1189 char *fpath
, *fuser
;
1191 p
= rparam
+ WORDSIZE
; /* skip result */
1192 GETWORD(p
, converter
, endp
);
1195 endp
= rdata
+ rdrcnt
;
1197 GETDWORD(p
, id
, endp
);
1198 GETWORD(p
, perms
, endp
);
1199 GETWORD(p
, locks
, endp
);
1201 p
+= rap_getstringp(frame
,
1207 rap_getstringp(frame
,
1214 if (fpath
&& fuser
) {
1215 fn(fpath
, fuser
, perms
, locks
, id
);
1220 DEBUG(4,("NetFileGetInfo2 res=%d\n", res
));
1224 DEBUG(4,("NetFileGetInfo2 failed\n"));
1233 /****************************************************************************
1234 * Call a NetFileEnum2 - list open files on an SMB server
1236 * PURPOSE: Remotes a NetFileEnum API call to the current server or target
1237 * server listing the files open via the network (and their
1238 * corresponding open instance ids)
1240 * Dependencies: none
1243 * cli - pointer to cli_state structure
1244 * user - if present, return only files opened by this remote user
1245 * base_path - if present, return only files opened below this
1247 * fn - display function to invoke for each entry in the result
1254 ****************************************************************************/
1256 int cli_NetFileEnum(struct cli_state
*cli
, const char * user
,
1257 const char * base_path
,
1258 void (*fn
)(const char *, const char *, uint16_t, uint16_t,
1261 char *rparam
= NULL
;
1264 unsigned int rdrcnt
,rprcnt
;
1265 char param
[WORDSIZE
/* api number */
1266 +sizeof(RAP_WFileEnum2_REQ
) /* req string */
1267 +sizeof(RAP_FILE_INFO_L3
) /* return string */
1268 +1024 /* base path (opt) */
1269 +RAP_USERNAME_LEN
/* user name (opt) */
1270 +WORDSIZE
/* info level */
1271 +WORDSIZE
/* buffer size */
1272 +DWORDSIZE
/* resume key ? */
1273 +DWORDSIZE
]; /* resume key ? */
1277 /* now send a SMBtrans command with api RNetShareEnum */
1278 p
= make_header(param
, RAP_WFileEnum2
,
1279 RAP_WFileEnum2_REQ
, RAP_FILE_INFO_L3
);
1281 PUTSTRING(p
, base_path
, 1024);
1282 PUTSTRING(p
, user
, RAP_USERNAME_LEN
);
1283 PUTWORD(p
, 3); /* info level */
1284 PUTWORD(p
, 0xFF00); /* buffer size */
1285 PUTDWORD(p
, 0); /* zero out the resume key */
1286 PUTDWORD(p
, 0); /* or is this one the resume key? */
1289 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
1290 NULL
, 0, 0xFF00, /* data, length, maxlen */
1291 &rparam
, &rprcnt
, /* return params, length */
1292 &rdata
, &rdrcnt
)) /* return data, length */
1294 char *endp
= rparam
+ rprcnt
;
1295 res
= GETRES(rparam
, endp
);
1297 if (res
== 0 || res
== ERRmoredata
) {
1298 TALLOC_CTX
*frame
= talloc_stackframe();
1299 int converter
= 0, i
;
1301 p
= rparam
+ WORDSIZE
; /* skip result */
1302 GETWORD(p
, converter
, endp
);
1303 GETWORD(p
, count
, endp
);
1306 endp
= rdata
+ rdrcnt
;
1307 for (i
=0; i
<count
&& p
< endp
; i
++) {
1308 int id
= 0, perms
= 0, locks
= 0;
1309 char *fpath
, *fuser
;
1311 GETDWORD(p
, id
, endp
);
1312 GETWORD(p
, perms
, endp
);
1313 GETWORD(p
, locks
, endp
);
1314 p
+= rap_getstringp(frame
,
1320 p
+= rap_getstringp(frame
,
1327 if (fpath
&& fuser
) {
1328 fn(fpath
, fuser
, perms
, locks
, id
);
1330 } /* BB fix ERRmoredata case to send resume request */
1333 DEBUG(4,("NetFileEnum2 res=%d\n", res
));
1336 DEBUG(4,("NetFileEnum2 failed\n"));
1345 /****************************************************************************
1346 Call a NetShareAdd - share/export directory on remote server.
1347 ****************************************************************************/
1349 int cli_NetShareAdd(struct cli_state
*cli
, struct rap_share_info_2
* sinfo
)
1351 char *rparam
= NULL
;
1354 unsigned int rdrcnt
,rprcnt
;
1356 char param
[WORDSIZE
/* api number */
1357 +sizeof(RAP_WShareAdd_REQ
) /* req string */
1358 +sizeof(RAP_SHARE_INFO_L2
) /* return string */
1359 +WORDSIZE
/* info level */
1360 +WORDSIZE
]; /* reserved word */
1362 /* offset to free format string section following fixed length data. */
1363 /* will be updated by PUTSTRINGP macro and will end up with total len */
1364 int soffset
= RAP_SHARENAME_LEN
+ 1 /* share name + pad */
1365 + WORDSIZE
/* share type */
1366 + DWORDSIZE
/* comment pointer */
1367 + WORDSIZE
/* permissions */
1368 + WORDSIZE
/* max users */
1369 + WORDSIZE
/* active users */
1370 + DWORDSIZE
/* share path */
1371 + RAP_SPASSWD_LEN
+ 1; /* share password + pad */
1373 memset(param
,'\0',sizeof(param
));
1374 /* now send a SMBtrans command with api RNetShareAdd */
1375 p
= make_header(param
, RAP_WshareAdd
,
1376 RAP_WShareAdd_REQ
, RAP_SHARE_INFO_L2
);
1377 PUTWORD(p
, 2); /* info level */
1378 PUTWORD(p
, 0); /* reserved word 0 */
1381 PUTSTRINGF(p
, (const char *)sinfo
->share_name
, RAP_SHARENAME_LEN
);
1382 PUTBYTE(p
, 0); /* pad byte 0 */
1384 PUTWORD(p
, sinfo
->share_type
);
1385 PUTSTRINGP(p
, sinfo
->comment
, data
, soffset
);
1386 PUTWORD(p
, sinfo
->perms
);
1387 PUTWORD(p
, sinfo
->maximum_users
);
1388 PUTWORD(p
, sinfo
->active_users
);
1389 PUTSTRINGP(p
, sinfo
->path
, data
, soffset
);
1390 PUTSTRINGF(p
, (const char *)sinfo
->password
, RAP_SPASSWD_LEN
);
1391 SCVAL(p
,-1,0x0A); /* required 0x0A at end of password */
1394 param
, sizeof(param
), 1024, /* Param, length, maxlen */
1395 data
, soffset
, sizeof(data
), /* data, length, maxlen */
1396 &rparam
, &rprcnt
, /* return params, length */
1397 &rdata
, &rdrcnt
)) /* return data, length */
1399 char *endp
= rparam
+ rprcnt
;
1400 res
= GETRES(rparam
, endp
);
1405 DEBUG(4,("NetShareAdd res=%d\n", res
));
1408 DEBUG(4,("NetShareAdd failed\n"));
1417 /****************************************************************************
1418 Call a NetShareDelete - unshare exported directory on remote server.
1419 ****************************************************************************/
1421 int cli_NetShareDelete(struct cli_state
*cli
, const char * share_name
)
1423 char *rparam
= NULL
;
1426 unsigned int rdrcnt
,rprcnt
;
1428 char param
[WORDSIZE
/* api number */
1429 +sizeof(RAP_WShareDel_REQ
) /* req string */
1430 +1 /* no ret string */
1431 +RAP_SHARENAME_LEN
/* share to del */
1432 +WORDSIZE
]; /* reserved word */
1434 /* now send a SMBtrans command with api RNetShareDelete */
1435 p
= make_header(param
, RAP_WshareDel
, RAP_WShareDel_REQ
, NULL
);
1436 PUTSTRING(p
,share_name
,RAP_SHARENAME_LEN
);
1437 PUTWORD(p
,0); /* reserved word MBZ on input */
1440 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
1441 NULL
, 0, 200, /* data, length, maxlen */
1442 &rparam
, &rprcnt
, /* return params, length */
1443 &rdata
, &rdrcnt
)) /* return data, length */
1445 char *endp
= rparam
+ rprcnt
;
1446 res
= GETRES(rparam
, endp
);
1451 DEBUG(4,("NetShareDelete res=%d\n", res
));
1454 DEBUG(4,("NetShareDelete failed\n"));
1463 /*************************************************************************
1465 * Function Name: cli_get_pdc_name
1467 * PURPOSE: Remotes a NetServerEnum API call to the current server
1468 * requesting the name of a server matching the server
1469 * type of SV_TYPE_DOMAIN_CTRL (PDC).
1471 * Dependencies: none
1474 * cli - pointer to cli_state structure
1475 * workgroup - pointer to string containing name of domain
1476 * pdc_name - pointer to string that will contain PDC name
1477 * on successful return
1483 ************************************************************************/
1485 bool cli_get_pdc_name(struct cli_state
*cli
, const char *workgroup
, char **pdc_name
)
1487 char *rparam
= NULL
;
1489 unsigned int rdrcnt
,rprcnt
;
1491 char param
[WORDSIZE
/* api number */
1492 +sizeof(RAP_NetServerEnum2_REQ
) /* req string */
1493 +sizeof(RAP_SERVER_INFO_L1
) /* return string */
1494 +WORDSIZE
/* info level */
1495 +WORDSIZE
/* buffer size */
1496 +DWORDSIZE
/* server type */
1497 +RAP_MACHNAME_LEN
]; /* workgroup */
1503 /* send a SMBtrans command with api NetServerEnum */
1504 p
= make_header(param
, RAP_NetServerEnum2
,
1505 RAP_NetServerEnum2_REQ
, RAP_SERVER_INFO_L1
);
1506 PUTWORD(p
, 1); /* info level */
1507 PUTWORD(p
, CLI_BUFFER_SIZE
);
1508 PUTDWORD(p
, SV_TYPE_DOMAIN_CTRL
);
1509 PUTSTRING(p
, workgroup
, RAP_MACHNAME_LEN
);
1512 param
, PTR_DIFF(p
,param
), 8, /* params, length, max */
1513 NULL
, 0, CLI_BUFFER_SIZE
, /* data, length, max */
1514 &rparam
, &rprcnt
, /* return params, return size */
1515 &rdata
, &rdrcnt
/* return data, return size */
1518 char *endp
= rparam
+ rprcnt
;
1519 res
= GETRES(rparam
, endp
);
1520 cli
->rap_error
= res
;
1523 * We only really care to copy a name if the
1524 * API succeeded and we got back a name.
1526 if (cli
->rap_error
== 0) {
1527 p
= rparam
+ WORDSIZE
+ WORDSIZE
; /* skip result and converter */
1528 GETWORD(p
, count
, endp
);
1530 endp
= rdata
+ rdrcnt
;
1533 TALLOC_CTX
*frame
= talloc_stackframe();
1535 rap_getstring(frame
,
1540 *pdc_name
= SMB_STRDUP(dcname
);
1545 DEBUG(4, ("cli_get_pdc_name: machine %s failed the "
1546 "NetServerEnum call. Error was : %s.\n",
1547 smbXcli_conn_remote_name(cli
->conn
),
1548 win_errstr(W_ERROR(cli
->rap_error
))));
1558 bool cli_get_server_name(TALLOC_CTX
*mem_ctx
, struct cli_state
*cli
,
1561 char *rparam
= NULL
;
1563 unsigned int rdrcnt
,rprcnt
;
1565 char param
[WORDSIZE
/* api number */
1566 +sizeof(RAP_WserverGetInfo_REQ
) /* req string */
1567 +sizeof(RAP_SERVER_INFO_L1
) /* return string */
1568 +WORDSIZE
/* info level */
1569 +WORDSIZE
]; /* buffer size */
1574 /* send a SMBtrans command with api NetServerGetInfo */
1575 p
= make_header(param
, RAP_WserverGetInfo
,
1576 RAP_WserverGetInfo_REQ
, RAP_SERVER_INFO_L1
);
1577 PUTWORD(p
, 1); /* info level */
1578 PUTWORD(p
, CLI_BUFFER_SIZE
);
1581 param
, PTR_DIFF(p
,param
), 8, /* params, length, max */
1582 NULL
, 0, CLI_BUFFER_SIZE
, /* data, length, max */
1583 &rparam
, &rprcnt
, /* return params, return size */
1584 &rdata
, &rdrcnt
/* return data, return size */
1589 endp
= rparam
+ rprcnt
;
1590 if (GETRES(rparam
, endp
) != 0) {
1595 DEBUG(10, ("invalid data count %d, expected >= 16\n", rdrcnt
));
1599 if (pull_ascii(tmp
, rdata
, sizeof(tmp
)-1, 16, STR_TERMINATE
) == -1) {
1600 DEBUG(10, ("pull_ascii failed\n"));
1604 if (!(*servername
= talloc_strdup(mem_ctx
, tmp
))) {
1605 DEBUG(1, ("talloc_strdup failed\n"));
1617 /*************************************************************************
1619 * Function Name: cli_ns_check_server_type
1621 * PURPOSE: Remotes a NetServerEnum2 API call to the current server
1622 * requesting server_info_0 level information of machines
1623 * matching the given server type. If the returned server
1624 * list contains the machine name contained in smbXcli_conn_remote_name(->conn)
1625 * then we conclude the server type checks out. This routine
1626 * is useful to retrieve list of server's of a certain
1627 * type when all you have is a null session connection and
1628 * can't remote API calls such as NetWkstaGetInfo or
1631 * Dependencies: none
1634 * cli - pointer to cli_state structure
1635 * workgroup - pointer to string containing domain
1636 * stype - server type
1642 ************************************************************************/
1644 bool cli_ns_check_server_type(struct cli_state
*cli
, char *workgroup
, uint32_t stype
)
1646 char *rparam
= NULL
;
1648 unsigned int rdrcnt
,rprcnt
;
1650 char param
[WORDSIZE
/* api number */
1651 +sizeof(RAP_NetServerEnum2_REQ
) /* req string */
1652 +sizeof(RAP_SERVER_INFO_L0
) /* return string */
1653 +WORDSIZE
/* info level */
1654 +WORDSIZE
/* buffer size */
1655 +DWORDSIZE
/* server type */
1656 +RAP_MACHNAME_LEN
]; /* workgroup */
1657 bool found_server
= false;
1659 const char *remote_name
= smbXcli_conn_remote_name(cli
->conn
);
1661 /* send a SMBtrans command with api NetServerEnum */
1662 p
= make_header(param
, RAP_NetServerEnum2
,
1663 RAP_NetServerEnum2_REQ
, RAP_SERVER_INFO_L0
);
1664 PUTWORD(p
, 0); /* info level 0 */
1665 PUTWORD(p
, CLI_BUFFER_SIZE
);
1667 PUTSTRING(p
, workgroup
, RAP_MACHNAME_LEN
);
1670 param
, PTR_DIFF(p
,param
), 8, /* params, length, max */
1671 NULL
, 0, CLI_BUFFER_SIZE
, /* data, length, max */
1672 &rparam
, &rprcnt
, /* return params, return size */
1673 &rdata
, &rdrcnt
/* return data, return size */
1675 char *endp
= rparam
+ rprcnt
;
1676 res
= GETRES(rparam
,endp
);
1677 cli
->rap_error
= res
;
1679 if (res
== 0 || res
== ERRmoredata
) {
1682 p
= rparam
+ WORDSIZE
+ WORDSIZE
;
1683 GETWORD(p
, count
,endp
);
1686 endp
= rdata
+ rdrcnt
;
1687 for (i
= 0;i
< count
&& p
< endp
;i
++, p
+= 16) {
1688 char ret_server
[RAP_MACHNAME_LEN
];
1690 p
+= rap_getstringf(p
,
1695 if (strequal(ret_server
, remote_name
)) {
1696 found_server
= true;
1701 DEBUG(4, ("cli_ns_check_server_type: machine %s "
1702 "failed the NetServerEnum call. Error was : "
1703 "%s.\n", remote_name
,
1704 win_errstr(W_ERROR(cli
->rap_error
))));
1711 return found_server
;
1714 /****************************************************************************
1715 Perform a NetWkstaUserLogoff.
1716 ****************************************************************************/
1718 bool cli_NetWkstaUserLogoff(struct cli_state
*cli
, const char *user
, const char *workstation
)
1720 char *rparam
= NULL
;
1723 unsigned int rdrcnt
,rprcnt
;
1724 char param
[WORDSIZE
/* api number */
1725 +sizeof(RAP_NetWkstaUserLogoff_REQ
) /* req string */
1726 +sizeof(RAP_USER_LOGOFF_INFO_L1
) /* return string */
1727 +RAP_USERNAME_LEN
+1 /* user name+pad */
1728 +RAP_MACHNAME_LEN
/* wksta name */
1729 +WORDSIZE
/* buffer size */
1730 +WORDSIZE
]; /* buffer size? */
1731 char upperbuf
[MAX(RAP_USERNAME_LEN
,RAP_MACHNAME_LEN
)];
1735 memset(param
, 0, sizeof(param
));
1737 /* send a SMBtrans command with api NetWkstaUserLogoff */
1738 p
= make_header(param
, RAP_WWkstaUserLogoff
,
1739 RAP_NetWkstaUserLogoff_REQ
, RAP_USER_LOGOFF_INFO_L1
);
1740 PUTDWORD(p
, 0); /* Null pointer */
1741 PUTDWORD(p
, 0); /* Null pointer */
1742 strlcpy(upperbuf
, user
, sizeof(upperbuf
));
1743 if (!strupper_m(upperbuf
)) {
1747 PUTSTRINGF(p
, tmp
, RAP_USERNAME_LEN
);
1748 p
++; /* strange format, but ok */
1749 strlcpy(upperbuf
, workstation
, sizeof(upperbuf
));
1750 if (!strupper_m(upperbuf
)) {
1754 PUTSTRINGF(p
, tmp
, RAP_MACHNAME_LEN
);
1755 PUTWORD(p
, CLI_BUFFER_SIZE
);
1756 PUTWORD(p
, CLI_BUFFER_SIZE
);
1759 param
, PTR_DIFF(p
,param
),1024, /* param, length, max */
1760 NULL
, 0, CLI_BUFFER_SIZE
, /* data, length, max */
1761 &rparam
, &rprcnt
, /* return params, return size */
1762 &rdata
, &rdrcnt
/* return data, return size */
1764 char *endp
= rparam
+ rprcnt
;
1765 res
= GETRES(rparam
,endp
);
1766 cli
->rap_error
= res
;
1768 if (cli
->rap_error
!= 0) {
1769 DEBUG(4,("NetwkstaUserLogoff gave error %d\n", cli
->rap_error
));
1775 return (cli
->rap_error
== 0);
1778 int cli_NetPrintQEnum(struct cli_state
*cli
,
1779 void (*qfn
)(const char*,uint16_t,uint16_t,uint16_t,const char*,const char*,const char*,const char*,const char*,uint16_t,uint16_t),
1780 void (*jfn
)(uint16_t,const char*,const char*,const char*,const char*,uint16_t,uint16_t,const char*,unsigned int,unsigned int,const char*))
1782 char param
[WORDSIZE
/* api number */
1783 +sizeof(RAP_NetPrintQEnum_REQ
) /* req string */
1784 +sizeof(RAP_PRINTQ_INFO_L2
) /* return string */
1785 +WORDSIZE
/* info level */
1786 +WORDSIZE
/* buffer size */
1787 +sizeof(RAP_SMB_PRINT_JOB_L1
)]; /* more ret data */
1789 char *rparam
= NULL
;
1791 unsigned int rprcnt
, rdrcnt
;
1794 memset(param
, '\0',sizeof(param
));
1795 p
= make_header(param
, RAP_WPrintQEnum
,
1796 RAP_NetPrintQEnum_REQ
, RAP_PRINTQ_INFO_L2
);
1797 PUTWORD(p
,2); /* Info level 2 */
1798 PUTWORD(p
,0xFFE0); /* Return buffer size */
1799 PUTSTRING(p
, RAP_SMB_PRINT_JOB_L1
, 0);
1802 param
, PTR_DIFF(p
,param
),1024,
1803 NULL
, 0, CLI_BUFFER_SIZE
,
1806 char *endp
= rparam
+ rprcnt
;
1807 res
= GETRES(rparam
, endp
);
1808 cli
->rap_error
= res
;
1810 DEBUG(1,("NetPrintQEnum gave error %d\n", res
));
1815 DEBUG(4,("NetPrintQEnum no data returned\n"));
1819 if (res
== 0 || res
== ERRmoredata
) {
1820 TALLOC_CTX
*frame
= talloc_stackframe();
1821 char *endp
= rparam
+ rprcnt
;
1822 int i
, converter
= 0, count
= 0;
1824 p
= rparam
+ WORDSIZE
;
1825 GETWORD(p
, converter
, endp
);
1826 GETWORD(p
, count
, endp
);
1829 endp
= rdata
+ rdrcnt
;
1830 for (i
=0;i
<count
&& p
< endp
;i
++) {
1831 char qname
[RAP_SHARENAME_LEN
];
1832 char *sep_file
, *print_proc
, *dest
, *parms
, *comment
;
1833 uint16_t jobcount
= 0, priority
= 0;
1834 uint16_t start_time
= 0, until_time
= 0, status
= 0;
1836 p
+= rap_getstringf(p
,
1842 GETWORD(p
, priority
, endp
);
1843 GETWORD(p
, start_time
, endp
);
1844 GETWORD(p
, until_time
, endp
);
1845 p
+= rap_getstringp(frame
,
1851 p
+= rap_getstringp(frame
,
1857 p
+= rap_getstringp(frame
,
1863 p
+= rap_getstringp(frame
,
1869 p
+= rap_getstringp(frame
,
1875 GETWORD(p
, status
, endp
);
1876 GETWORD(p
, jobcount
, endp
);
1878 if (sep_file
&& print_proc
&& dest
&& parms
&&
1880 qfn(qname
, priority
, start_time
, until_time
, sep_file
, print_proc
,
1881 dest
, parms
, comment
, status
, jobcount
);
1886 for (j
=0;j
<jobcount
;j
++) {
1887 uint16_t jid
= 0, pos
= 0, fsstatus
= 0;
1888 char ownername
[RAP_USERNAME_LEN
];
1889 char notifyname
[RAP_MACHNAME_LEN
];
1890 char datatype
[RAP_DATATYPE_LEN
];
1891 char *jparms
, *jstatus
, *jcomment
;
1892 unsigned int submitted
= 0, jsize
= 0;
1894 GETWORD(p
, jid
, endp
);
1895 p
+= rap_getstringf(p
,
1901 p
+= rap_getstringf(p
,
1906 p
+= rap_getstringf(p
,
1911 p
+= rap_getstringp(frame
,
1917 GETWORD(p
, pos
, endp
);
1918 GETWORD(p
, fsstatus
, endp
);
1919 p
+= rap_getstringp(frame
,
1925 GETDWORD(p
, submitted
, endp
);
1926 GETDWORD(p
, jsize
, endp
);
1927 p
+= rap_getstringp(frame
,
1934 if (jparms
&& jstatus
&& jcomment
) {
1935 jfn(jid
, ownername
, notifyname
, datatype
, jparms
, pos
, fsstatus
,
1936 jstatus
, submitted
, jsize
, jcomment
);
1943 DEBUG(4,("NetPrintQEnum res=%d\n", res
));
1954 int cli_NetPrintQGetInfo(struct cli_state
*cli
, const char *printer
,
1955 void (*qfn
)(const char*,uint16_t,uint16_t,uint16_t,const char*,const char*,const char*,const char*,const char*,uint16_t,uint16_t),
1956 void (*jfn
)(uint16_t,const char*,const char*,const char*,const char*,uint16_t,uint16_t,const char*,unsigned int,unsigned int,const char*))
1958 char param
[WORDSIZE
/* api number */
1959 +sizeof(RAP_NetPrintQGetInfo_REQ
) /* req string */
1960 +sizeof(RAP_PRINTQ_INFO_L2
) /* return string */
1961 +RAP_SHARENAME_LEN
/* printer name */
1962 +WORDSIZE
/* info level */
1963 +WORDSIZE
/* buffer size */
1964 +sizeof(RAP_SMB_PRINT_JOB_L1
)]; /* more ret data */
1966 char *rparam
= NULL
;
1968 unsigned int rprcnt
, rdrcnt
;
1971 memset(param
, '\0',sizeof(param
));
1972 p
= make_header(param
, RAP_WPrintQGetInfo
,
1973 RAP_NetPrintQGetInfo_REQ
, RAP_PRINTQ_INFO_L2
);
1974 PUTSTRING(p
, printer
, RAP_SHARENAME_LEN
-1);
1975 PUTWORD(p
, 2); /* Info level 2 */
1976 PUTWORD(p
,0xFFE0); /* Return buffer size */
1977 PUTSTRING(p
, RAP_SMB_PRINT_JOB_L1
, 0);
1980 param
, PTR_DIFF(p
,param
),1024,
1981 NULL
, 0, CLI_BUFFER_SIZE
,
1984 char *endp
= rparam
+ rprcnt
;
1985 res
= GETRES(rparam
, endp
);
1986 cli
->rap_error
= res
;
1988 DEBUG(1,("NetPrintQGetInfo gave error %d\n", res
));
1993 DEBUG(4,("NetPrintQGetInfo no data returned\n"));
1997 if (res
== 0 || res
== ERRmoredata
) {
1998 TALLOC_CTX
*frame
= talloc_stackframe();
1999 char *endp
= rparam
+ rprcnt
;
2000 int rsize
= 0, converter
= 0;
2001 char qname
[RAP_SHARENAME_LEN
];
2002 char *sep_file
, *print_proc
, *dest
, *parms
, *comment
;
2003 uint16_t jobcount
= 0, priority
= 0;
2004 uint16_t start_time
= 0, until_time
= 0, status
= 0;
2006 p
= rparam
+ WORDSIZE
;
2007 GETWORD(p
, converter
, endp
);
2008 GETWORD(p
, rsize
, endp
);
2011 endp
= rdata
+ rdrcnt
;
2012 p
+= rap_getstringf(p
,
2018 GETWORD(p
, priority
, endp
);
2019 GETWORD(p
, start_time
, endp
);
2020 GETWORD(p
, until_time
, endp
);
2021 p
+= rap_getstringp(frame
,
2027 p
+= rap_getstringp(frame
,
2033 p
+= rap_getstringp(frame
,
2039 p
+= rap_getstringp(frame
,
2045 p
+= rap_getstringp(frame
,
2051 GETWORD(p
, status
, endp
);
2052 GETWORD(p
, jobcount
, endp
);
2054 if (sep_file
&& print_proc
&& dest
&&
2056 qfn(qname
, priority
, start_time
, until_time
, sep_file
, print_proc
,
2057 dest
, parms
, comment
, status
, jobcount
);
2061 for (j
=0;(j
<jobcount
)&&(PTR_DIFF(p
,rdata
)< rsize
)&&
2063 uint16_t jid
= 0, pos
= 0, fsstatus
= 0;
2064 char ownername
[RAP_USERNAME_LEN
];
2065 char notifyname
[RAP_MACHNAME_LEN
];
2066 char datatype
[RAP_DATATYPE_LEN
];
2067 char *jparms
, *jstatus
, *jcomment
;
2068 unsigned int submitted
= 0, jsize
= 0;
2070 GETWORD(p
, jid
, endp
);
2071 p
+= rap_getstringf(p
,
2077 p
+= rap_getstringf(p
,
2082 p
+= rap_getstringf(p
,
2087 p
+= rap_getstringp(frame
,
2093 GETWORD(p
, pos
,endp
);
2094 GETWORD(p
, fsstatus
,endp
);
2095 p
+= rap_getstringp(frame
,
2101 GETDWORD(p
, submitted
,endp
);
2102 GETDWORD(p
, jsize
,endp
);
2103 p
+= rap_getstringp(frame
,
2110 if (jparms
&& jstatus
&& jcomment
) {
2111 jfn(jid
, ownername
, notifyname
, datatype
, jparms
, pos
, fsstatus
,
2112 jstatus
, submitted
, jsize
, jcomment
);
2118 DEBUG(4,("NetPrintQGetInfo res=%d\n", res
));
2129 /****************************************************************************
2130 Call a NetServiceEnum - list running services on a different host.
2131 ****************************************************************************/
2133 int cli_RNetServiceEnum(struct cli_state
*cli
, void (*fn
)(const char *, const char *, void *), void *state
)
2135 char param
[WORDSIZE
/* api number */
2136 +sizeof(RAP_NetServiceEnum_REQ
) /* parm string */
2137 +sizeof(RAP_SERVICE_INFO_L2
) /* return string */
2138 +WORDSIZE
/* info level */
2139 +WORDSIZE
]; /* buffer size */
2141 char *rparam
= NULL
;
2143 unsigned int rprcnt
, rdrcnt
;
2146 memset(param
, '\0', sizeof(param
));
2147 p
= make_header(param
, RAP_WServiceEnum
,
2148 RAP_NetServiceEnum_REQ
, RAP_SERVICE_INFO_L2
);
2149 PUTWORD(p
,2); /* Info level 2 */
2150 PUTWORD(p
,0xFFE0); /* Return buffer size */
2153 param
, PTR_DIFF(p
,param
),8,
2154 NULL
, 0, 0xFFE0 /* data area size */,
2157 char *endp
= rparam
+ rprcnt
;
2158 res
= GETRES(rparam
, endp
);
2159 cli
->rap_error
= res
;
2160 if(cli
->rap_error
== 234) {
2161 DEBUG(1,("Not all service names were returned (such as those longer than 15 characters)\n"));
2162 } else if (cli
->rap_error
!= 0) {
2163 DEBUG(1,("NetServiceEnum gave error %d\n", cli
->rap_error
));
2168 DEBUG(4,("NetServiceEnum no data returned\n"));
2172 if (res
== 0 || res
== ERRmoredata
) {
2173 char *endp
= rparam
+ rprcnt
;
2176 p
= rparam
+ WORDSIZE
+ WORDSIZE
; /* skip result and converter */
2177 GETWORD(p
, count
,endp
);
2179 endp
= rdata
+ rdrcnt
;
2180 for (i
=0,p
=rdata
;i
<count
&& p
< endp
;i
++) {
2181 char comment
[RAP_SRVCCMNT_LEN
];
2182 char servicename
[RAP_SRVCNAME_LEN
];
2184 p
+= rap_getstringf(p
,
2189 p
+=8; /* pass status words */
2190 p
+= rap_getstringf(p
,
2196 if (servicename
[0]) {
2197 fn(servicename
, comment
, cli
); /* BB add status too */
2201 DEBUG(4,("NetServiceEnum res=%d\n", res
));
2212 /****************************************************************************
2213 Call a NetSessionEnum - list workstations with sessions to an SMB server.
2214 ****************************************************************************/
2216 int cli_NetSessionEnum(struct cli_state
*cli
, void (*fn
)(char *, char *, uint16_t, uint16_t, uint16_t, unsigned int, unsigned int, unsigned int, char *))
2218 char param
[WORDSIZE
/* api number */
2219 +sizeof(RAP_NetSessionEnum_REQ
) /* parm string */
2220 +sizeof(RAP_SESSION_INFO_L2
) /* return string */
2221 +WORDSIZE
/* info level */
2222 +WORDSIZE
]; /* buffer size */
2224 char *rparam
= NULL
;
2226 unsigned int rprcnt
, rdrcnt
;
2229 memset(param
, '\0', sizeof(param
));
2230 p
= make_header(param
, RAP_WsessionEnum
,
2231 RAP_NetSessionEnum_REQ
, RAP_SESSION_INFO_L2
);
2232 PUTWORD(p
,2); /* Info level 2 */
2233 PUTWORD(p
,0xFF); /* Return buffer size */
2236 param
, PTR_DIFF(p
,param
),8,
2237 NULL
, 0, CLI_BUFFER_SIZE
,
2240 char *endp
= rparam
+ rprcnt
;
2241 res
= GETRES(rparam
, endp
);
2242 cli
->rap_error
= res
;
2244 DEBUG(1,("NetSessionEnum gave error %d\n", res
));
2249 DEBUG(4,("NetSessionEnum no data returned\n"));
2253 if (res
== 0 || res
== ERRmoredata
) {
2254 TALLOC_CTX
*frame
= talloc_stackframe();
2255 char *endp
= rparam
+ rprcnt
;
2256 int i
, converter
= 0, count
= 0;
2258 p
= rparam
+ WORDSIZE
;
2259 GETWORD(p
, converter
, endp
);
2260 GETWORD(p
, count
, endp
);
2262 endp
= rdata
+ rdrcnt
;
2263 for (i
=0,p
=rdata
;i
<count
&& p
< endp
;i
++) {
2264 char *wsname
, *username
, *clitype_name
;
2265 uint16_t num_conns
= 0, num_opens
= 0, num_users
= 0;
2266 unsigned int sess_time
= 0, idle_time
= 0, user_flags
= 0;
2268 p
+= rap_getstringp(frame
,
2274 p
+= rap_getstringp(frame
,
2280 GETWORD(p
, num_conns
, endp
);
2281 GETWORD(p
, num_opens
, endp
);
2282 GETWORD(p
, num_users
, endp
);
2283 GETDWORD(p
, sess_time
, endp
);
2284 GETDWORD(p
, idle_time
, endp
);
2285 GETDWORD(p
, user_flags
, endp
);
2286 p
+= rap_getstringp(frame
,
2293 if (wsname
&& username
&& clitype_name
) {
2294 fn(wsname
, username
, num_conns
, num_opens
, num_users
, sess_time
,
2295 idle_time
, user_flags
, clitype_name
);
2300 DEBUG(4,("NetSessionEnum res=%d\n", res
));
2311 /****************************************************************************
2312 Call a NetSessionGetInfo - get information about other session to an SMB server.
2313 ****************************************************************************/
2315 int cli_NetSessionGetInfo(struct cli_state
*cli
, const char *workstation
,
2316 void (*fn
)(const char *, const char *, uint16_t, uint16_t, uint16_t, unsigned int, unsigned int, unsigned int, const char *))
2318 char param
[WORDSIZE
/* api number */
2319 +sizeof(RAP_NetSessionGetInfo_REQ
) /* req string */
2320 +sizeof(RAP_SESSION_INFO_L2
) /* return string */
2321 +RAP_MACHNAME_LEN
/* wksta name */
2322 +WORDSIZE
/* info level */
2323 +WORDSIZE
]; /* buffer size */
2325 char *rparam
= NULL
;
2327 unsigned int rprcnt
, rdrcnt
;
2331 memset(param
, '\0', sizeof(param
));
2332 p
= make_header(param
, RAP_WsessionGetInfo
,
2333 RAP_NetSessionGetInfo_REQ
, RAP_SESSION_INFO_L2
);
2334 PUTSTRING(p
, workstation
, RAP_MACHNAME_LEN
-1);
2335 PUTWORD(p
,2); /* Info level 2 */
2336 PUTWORD(p
,0xFF); /* Return buffer size */
2339 param
, PTR_DIFF(p
,param
),PTR_DIFF(p
,param
),
2340 NULL
, 0, CLI_BUFFER_SIZE
,
2343 endp
= rparam
+ rprcnt
;
2344 res
= GETRES(rparam
, endp
);
2345 cli
->rap_error
= res
;
2346 if (cli
->rap_error
!= 0) {
2347 DEBUG(1,("NetSessionGetInfo gave error %d\n", cli
->rap_error
));
2352 DEBUG(4,("NetSessionGetInfo no data returned\n"));
2356 endp
= rparam
+ rprcnt
;
2357 res
= GETRES(rparam
, endp
);
2359 if (res
== 0 || res
== ERRmoredata
) {
2360 TALLOC_CTX
*frame
= talloc_stackframe();
2362 char *wsname
, *username
, *clitype_name
;
2363 uint16_t num_conns
= 0, num_opens
= 0, num_users
= 0;
2364 unsigned int sess_time
= 0, idle_time
= 0, user_flags
= 0;
2366 p
= rparam
+ WORDSIZE
;
2367 GETWORD(p
, converter
,endp
);
2370 endp
= rdata
+ rdrcnt
;
2371 p
+= rap_getstringp(frame
,
2377 p
+= rap_getstringp(frame
,
2383 GETWORD(p
, num_conns
, endp
);
2384 GETWORD(p
, num_opens
, endp
);
2385 GETWORD(p
, num_users
, endp
);
2386 GETDWORD(p
, sess_time
, endp
);
2387 GETDWORD(p
, idle_time
, endp
);
2388 GETDWORD(p
, user_flags
, endp
);
2389 rap_getstringp(frame
,
2396 if (wsname
&& username
&& clitype_name
) {
2397 fn(wsname
, username
, num_conns
, num_opens
, num_users
, sess_time
,
2398 idle_time
, user_flags
, clitype_name
);
2402 DEBUG(4,("NetSessionGetInfo res=%d\n", res
));
2413 /****************************************************************************
2414 Call a NetSessionDel - close a session to an SMB server.
2415 ****************************************************************************/
2417 int cli_NetSessionDel(struct cli_state
*cli
, const char *workstation
)
2419 char param
[WORDSIZE
/* api number */
2420 +sizeof(RAP_NetSessionDel_REQ
) /* req string */
2421 +1 /* no return string */
2422 +RAP_MACHNAME_LEN
/* workstation name */
2423 +WORDSIZE
]; /* reserved (0) */
2425 char *rparam
= NULL
;
2427 unsigned int rprcnt
, rdrcnt
;
2430 memset(param
, '\0', sizeof(param
));
2431 p
= make_header(param
, RAP_WsessionDel
, RAP_NetSessionDel_REQ
, NULL
);
2432 PUTSTRING(p
, workstation
, RAP_MACHNAME_LEN
-1);
2433 PUTWORD(p
,0); /* reserved word of 0 */
2436 param
, PTR_DIFF(p
,param
), 1024, /* Param, length, maxlen */
2437 NULL
, 0, 200, /* data, length, maxlen */
2438 &rparam
, &rprcnt
, /* return params, length */
2439 &rdata
, &rdrcnt
)) /* return data, length */
2441 char *endp
= rparam
+ rprcnt
;
2442 res
= GETRES(rparam
, endp
);
2443 cli
->rap_error
= res
;
2448 DEBUG(4,("NetFileClose2 res=%d\n", res
));
2452 DEBUG(4,("NetFileClose2 failed\n"));
2461 int cli_NetConnectionEnum(struct cli_state
*cli
, const char *qualifier
,
2462 void (*fn
)(uint16_t conid
, uint16_t contype
,
2463 uint16_t numopens
, uint16_t numusers
,
2464 uint32_t contime
, const char *username
,
2465 const char *netname
))
2467 char param
[WORDSIZE
/* api number */
2468 +sizeof(RAP_NetConnectionEnum_REQ
) /* req string */
2469 +sizeof(RAP_CONNECTION_INFO_L1
) /* return string */
2470 +RAP_MACHNAME_LEN
/* wksta name */
2471 +WORDSIZE
/* info level */
2472 +WORDSIZE
]; /* buffer size */
2474 char *rparam
= NULL
;
2476 unsigned int rprcnt
, rdrcnt
;
2479 memset(param
, '\0', sizeof(param
));
2480 p
= make_header(param
, RAP_WconnectionEnum
,
2481 RAP_NetConnectionEnum_REQ
, RAP_CONNECTION_INFO_L1
);
2482 PUTSTRING(p
, qualifier
, RAP_MACHNAME_LEN
-1);/* Workstation name */
2483 PUTWORD(p
,1); /* Info level 1 */
2484 PUTWORD(p
,0xFFE0); /* Return buffer size */
2487 param
, PTR_DIFF(p
,param
),PTR_DIFF(p
,param
),
2488 NULL
, 0, CLI_BUFFER_SIZE
,
2491 char *endp
= rparam
+ rprcnt
;
2492 res
= GETRES(rparam
, endp
);
2493 cli
->rap_error
= res
;
2495 DEBUG(1,("NetConnectionEnum gave error %d\n", res
));
2500 DEBUG(4,("NetConnectionEnum no data returned\n"));
2504 if (res
== 0 || res
== ERRmoredata
) {
2505 TALLOC_CTX
*frame
= talloc_stackframe();
2506 char *endp
= rparam
+ rprcnt
;
2507 int i
, converter
= 0, count
= 0;
2509 p
= rparam
+ WORDSIZE
;
2510 GETWORD(p
, converter
, endp
);
2511 GETWORD(p
, count
, endp
);
2513 endp
= rdata
+ rdrcnt
;
2514 for (i
=0,p
=rdata
;i
<count
&& p
< endp
;i
++) {
2515 char *netname
, *username
;
2516 uint16_t conn_id
= 0, conn_type
= 0, num_opens
= 0, num_users
= 0;
2517 unsigned int conn_time
= 0;
2519 GETWORD(p
,conn_id
, endp
);
2520 GETWORD(p
,conn_type
, endp
);
2521 GETWORD(p
,num_opens
, endp
);
2522 GETWORD(p
,num_users
, endp
);
2523 GETDWORD(p
,conn_time
, endp
);
2524 p
+= rap_getstringp(frame
,
2530 p
+= rap_getstringp(frame
,
2537 if (username
&& netname
) {
2538 fn(conn_id
, conn_type
, num_opens
, num_users
, conn_time
,
2544 DEBUG(4,("NetConnectionEnum res=%d\n", res
));