source: vendor/current/source3/lib/netapi/wkstainfo.c

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 4.6 KB
Line 
1/*
2 * Unix SMB/CIFS implementation.
3 * NetApi Workstation Support
4 * Copyright (C) Guenther Deschner 2007
5 * Copyright (C) Hans Leidekker 2013
6 *
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.
11 *
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.
16 *
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/>.
19 */
20
21#include "includes.h"
22
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"
30
31/****************************************************************
32****************************************************************/
33
34WERROR NetWkstaGetInfo_l(struct libnetapi_ctx *ctx,
35 struct NetWkstaGetInfo *r)
36{
37 LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetWkstaGetInfo);
38}
39
40/****************************************************************
41****************************************************************/
42
43static NTSTATUS map_wksta_info_to_WKSTA_INFO_buffer(TALLOC_CTX *mem_ctx,
44 uint32_t level,
45 union wkssvc_NetWkstaInfo *i,
46 uint8_t **buffer)
47{
48 struct WKSTA_INFO_100 i100;
49 struct WKSTA_INFO_101 i101;
50 struct WKSTA_INFO_102 i102;
51 uint32_t num_info = 0;
52
53 switch (level) {
54 case 100:
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;
60
61 ADD_TO_ARRAY(mem_ctx, struct WKSTA_INFO_100, i100,
62 (struct WKSTA_INFO_100 **)buffer,
63 &num_info);
64 break;
65
66 case 101:
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);
73
74 ADD_TO_ARRAY(mem_ctx, struct WKSTA_INFO_101, i101,
75 (struct WKSTA_INFO_101 **)buffer,
76 &num_info);
77 break;
78
79 case 102:
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;
87
88 ADD_TO_ARRAY(mem_ctx, struct WKSTA_INFO_102, i102,
89 (struct WKSTA_INFO_102 **)buffer,
90 &num_info);
91 break;
92
93 default:
94 return NT_STATUS_NOT_SUPPORTED;
95 }
96
97 return NT_STATUS_OK;
98}
99
100/****************************************************************
101****************************************************************/
102
103WERROR NetWkstaGetInfo_r(struct libnetapi_ctx *ctx,
104 struct NetWkstaGetInfo *r)
105{
106 NTSTATUS status;
107 WERROR werr;
108 union wkssvc_NetWkstaInfo info;
109 struct dcerpc_binding_handle *b;
110
111 if (!r->out.buffer) {
112 return WERR_INVALID_PARAM;
113 }
114
115 switch (r->in.level) {
116 case 100:
117 case 101:
118 case 102:
119 break;
120 default:
121 return WERR_UNKNOWN_LEVEL;
122 }
123
124 werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
125 &ndr_table_wkssvc,
126 &b);
127 if (!W_ERROR_IS_OK(werr)) {
128 goto done;
129 }
130
131 status = dcerpc_wkssvc_NetWkstaGetInfo(b, talloc_tos(),
132 r->in.server_name,
133 r->in.level,
134 &info,
135 &werr);
136 if (!NT_STATUS_IS_OK(status)) {
137 werr = ntstatus_to_werror(status);
138 goto done;
139 }
140
141 if (!W_ERROR_IS_OK(werr)) {
142 goto done;
143 }
144
145 status = map_wksta_info_to_WKSTA_INFO_buffer(ctx, r->in.level, &info,
146 r->out.buffer);
147 if (!NT_STATUS_IS_OK(status)) {
148 werr = ntstatus_to_werror(status);
149 goto done;
150 }
151
152 done:
153 return werr;
154}
Note: See TracBrowser for help on using the repository browser.