2 * Unix SMB/CIFS implementation.
3 * NetApi Workstation Support
4 * Copyright (C) Guenther Deschner 2007
5 * Copyright (C) Hans Leidekker 2013
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
23 #include "librpc/gen_ndr/libnetapi.h"
24 #include "lib/netapi/netapi.h"
25 #include "lib/netapi/netapi_private.h"
26 #include "lib/netapi/libnetapi.h"
27 #include "../librpc/gen_ndr/ndr_wkssvc_c.h"
28 #include "lib/smbconf/smbconf.h"
29 #include "lib/smbconf/smbconf_reg.h"
31 /****************************************************************
32 ****************************************************************/
34 WERROR
NetWkstaGetInfo_l(struct libnetapi_ctx
*ctx
,
35 struct NetWkstaGetInfo
*r
)
37 LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx
, r
, NetWkstaGetInfo
);
40 /****************************************************************
41 ****************************************************************/
43 static NTSTATUS
map_wksta_info_to_WKSTA_INFO_buffer(TALLOC_CTX
*mem_ctx
,
45 union wkssvc_NetWkstaInfo
*i
,
48 struct WKSTA_INFO_100 i100
;
49 struct WKSTA_INFO_101 i101
;
50 struct WKSTA_INFO_102 i102
;
51 uint32_t num_info
= 0;
55 i100
.wki100_platform_id
= i
->info100
->platform_id
;
56 i100
.wki100_computername
= talloc_strdup(mem_ctx
, i
->info100
->server_name
);
57 i100
.wki100_langroup
= talloc_strdup(mem_ctx
, i
->info100
->domain_name
);
58 i100
.wki100_ver_major
= i
->info100
->version_major
;
59 i100
.wki100_ver_minor
= i
->info100
->version_minor
;
61 ADD_TO_ARRAY(mem_ctx
, struct WKSTA_INFO_100
, i100
,
62 (struct WKSTA_INFO_100
**)buffer
,
67 i101
.wki101_platform_id
= i
->info101
->platform_id
;
68 i101
.wki101_computername
= talloc_strdup(mem_ctx
, i
->info101
->server_name
);
69 i101
.wki101_langroup
= talloc_strdup(mem_ctx
, i
->info101
->domain_name
);
70 i101
.wki101_ver_major
= i
->info101
->version_major
;
71 i101
.wki101_ver_minor
= i
->info101
->version_minor
;
72 i101
.wki101_lanroot
= talloc_strdup(mem_ctx
, i
->info101
->lan_root
);
74 ADD_TO_ARRAY(mem_ctx
, struct WKSTA_INFO_101
, i101
,
75 (struct WKSTA_INFO_101
**)buffer
,
80 i102
.wki102_platform_id
= i
->info102
->platform_id
;
81 i102
.wki102_computername
= talloc_strdup(mem_ctx
, i
->info102
->server_name
);
82 i102
.wki102_langroup
= talloc_strdup(mem_ctx
, i
->info102
->domain_name
);
83 i102
.wki102_ver_major
= i
->info102
->version_major
;
84 i102
.wki102_ver_minor
= i
->info102
->version_minor
;
85 i102
.wki102_lanroot
= talloc_strdup(mem_ctx
, i
->info102
->lan_root
);
86 i102
.wki102_logged_on_users
= i
->info102
->logged_on_users
;
88 ADD_TO_ARRAY(mem_ctx
, struct WKSTA_INFO_102
, i102
,
89 (struct WKSTA_INFO_102
**)buffer
,
94 return NT_STATUS_NOT_SUPPORTED
;
100 /****************************************************************
101 ****************************************************************/
103 WERROR
NetWkstaGetInfo_r(struct libnetapi_ctx
*ctx
,
104 struct NetWkstaGetInfo
*r
)
108 union wkssvc_NetWkstaInfo info
;
109 struct dcerpc_binding_handle
*b
;
111 if (!r
->out
.buffer
) {
112 return WERR_INVALID_PARAMETER
;
115 switch (r
->in
.level
) {
121 return WERR_INVALID_LEVEL
;
124 werr
= libnetapi_get_binding_handle(ctx
, r
->in
.server_name
,
127 if (!W_ERROR_IS_OK(werr
)) {
131 status
= dcerpc_wkssvc_NetWkstaGetInfo(b
, talloc_tos(),
136 if (!NT_STATUS_IS_OK(status
)) {
137 werr
= ntstatus_to_werror(status
);
141 if (!W_ERROR_IS_OK(werr
)) {
145 status
= map_wksta_info_to_WKSTA_INFO_buffer(ctx
, r
->in
.level
, &info
,
147 if (!NT_STATUS_IS_OK(status
)) {
148 werr
= ntstatus_to_werror(status
);