2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Guenther Deschner 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include <sys/types.h>
30 static NET_API_STATUS
test_netquerydisplayinformation(const char *hostname
,
34 NET_API_STATUS status
;
35 uint32_t entries_read
= 0;
37 const char *current_name
;
38 uint8_t *buffer
= NULL
;
42 struct NET_DISPLAY_USER
*user
;
43 struct NET_DISPLAY_GROUP
*group
;
44 struct NET_DISPLAY_MACHINE
*machine
;
46 printf("testing NetQueryDisplayInformation level %d\n", level
);
49 status
= NetQueryDisplayInformation(hostname
,
56 if (status
== 0 || status
== ERROR_MORE_DATA
) {
59 user
= (struct NET_DISPLAY_USER
*)buffer
;
62 machine
= (struct NET_DISPLAY_MACHINE
*)buffer
;
65 group
= (struct NET_DISPLAY_GROUP
*)buffer
;
71 for (i
=0; i
<entries_read
; i
++) {
75 current_name
= user
->usri1_name
;
78 current_name
= machine
->usri2_name
;
81 current_name
= group
->grpi3_name
;
87 if (name
&& strcasecmp(current_name
, name
) == 0) {
103 NetApiBufferFree(buffer
);
106 } while (status
== ERROR_MORE_DATA
);
112 if (name
&& !found_name
) {
113 printf("failed to get name\n");
120 NET_API_STATUS
netapitest_display(struct libnetapi_ctx
*ctx
,
121 const char *hostname
)
123 NET_API_STATUS status
= 0;
124 uint32_t levels
[] = { 1, 2, 3};
127 printf("NetDisplay tests\n");
131 for (i
=0; i
<ARRAY_SIZE(levels
); i
++) {
133 status
= test_netquerydisplayinformation(hostname
, levels
[i
], NULL
);
135 NETAPI_STATUS(ctx
, status
, "NetQueryDisplayInformation");
142 printf("NetDisplay tests succeeded\n");
145 printf("NetDisplay testsuite failed with: %s\n",
146 libnetapi_get_error_string(ctx
, status
));