smbconf: only include smbconf headers where needed.
[gd/samba-autobuild/.git] / source3 / lib / netapi / serverinfo.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  NetApi Server Support
4  *  Copyright (C) Guenther Deschner 2007
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 #include "includes.h"
21
22 #include "librpc/gen_ndr/libnetapi.h"
23 #include "lib/netapi/netapi.h"
24 #include "lib/netapi/netapi_private.h"
25 #include "lib/netapi/libnetapi.h"
26 #include "../librpc/gen_ndr/cli_srvsvc.h"
27 #include "lib/smbconf/smbconf.h"
28 #include "lib/smbconf/smbconf_reg.h"
29
30 /****************************************************************
31 ****************************************************************/
32
33 static WERROR NetServerGetInfo_l_101(struct libnetapi_ctx *ctx,
34                                      uint8_t **buffer)
35 {
36         struct SERVER_INFO_101 i;
37
38         i.sv101_platform_id     = PLATFORM_ID_NT;
39         i.sv101_name            = global_myname();
40         i.sv101_version_major   = lp_major_announce_version();
41         i.sv101_version_minor   = lp_minor_announce_version();
42         i.sv101_type            = lp_default_server_announce();
43         i.sv101_comment         = lp_serverstring();
44
45         *buffer = (uint8_t *)talloc_memdup(ctx, &i, sizeof(i));
46         if (!*buffer) {
47                 return WERR_NOMEM;
48         }
49
50         return WERR_OK;
51 }
52
53 /****************************************************************
54 ****************************************************************/
55
56 static WERROR NetServerGetInfo_l_1005(struct libnetapi_ctx *ctx,
57                                       uint8_t **buffer)
58 {
59         struct SERVER_INFO_1005 info1005;
60
61         info1005.sv1005_comment = lp_serverstring();
62         *buffer = (uint8_t *)talloc_memdup(ctx, &info1005, sizeof(info1005));
63         if (!*buffer) {
64                 return WERR_NOMEM;
65         }
66
67         return WERR_OK;
68 }
69
70 /****************************************************************
71 ****************************************************************/
72
73 WERROR NetServerGetInfo_l(struct libnetapi_ctx *ctx,
74                           struct NetServerGetInfo *r)
75 {
76         switch (r->in.level) {
77                 case 101:
78                         return NetServerGetInfo_l_101(ctx, r->out.buffer);
79                 case 1005:
80                         return NetServerGetInfo_l_1005(ctx, r->out.buffer);
81                 default:
82                         break;
83         }
84
85         return WERR_UNKNOWN_LEVEL;
86 }
87
88 /****************************************************************
89 ****************************************************************/
90
91 static NTSTATUS map_server_info_to_SERVER_INFO_buffer(TALLOC_CTX *mem_ctx,
92                                                       uint32_t level,
93                                                       union srvsvc_NetSrvInfo *i,
94                                                       uint8_t **buffer)
95 {
96         struct SERVER_INFO_100 i100;
97         struct SERVER_INFO_101 i101;
98         struct SERVER_INFO_102 i102;
99         struct SERVER_INFO_402 i402;
100         struct SERVER_INFO_403 i403;
101         struct SERVER_INFO_502 i502;
102         struct SERVER_INFO_503 i503;
103         struct SERVER_INFO_599 i599;
104         struct SERVER_INFO_1005 i1005;
105 #if 0
106         struct SERVER_INFO_1010 i1010;
107         struct SERVER_INFO_1016 i1016;
108         struct SERVER_INFO_1017 i1017;
109         struct SERVER_INFO_1018 i1018;
110         struct SERVER_INFO_1107 i1107;
111         struct SERVER_INFO_1501 i1501;
112         struct SERVER_INFO_1502 i1502;
113         struct SERVER_INFO_1503 i1503;
114         struct SERVER_INFO_1506 i1506;
115         struct SERVER_INFO_1509 i1509;
116         struct SERVER_INFO_1510 i1510;
117         struct SERVER_INFO_1511 i1511;
118         struct SERVER_INFO_1512 i1512;
119         struct SERVER_INFO_1513 i1513;
120         struct SERVER_INFO_1514 i1514;
121         struct SERVER_INFO_1515 i1515;
122         struct SERVER_INFO_1516 i1516;
123         struct SERVER_INFO_1518 i1518;
124         struct SERVER_INFO_1520 i1520;
125         struct SERVER_INFO_1521 i1521;
126         struct SERVER_INFO_1522 i1522;
127         struct SERVER_INFO_1523 i1523;
128         struct SERVER_INFO_1524 i1524;
129         struct SERVER_INFO_1525 i1525;
130         struct SERVER_INFO_1528 i1528;
131         struct SERVER_INFO_1529 i1529;
132         struct SERVER_INFO_1530 i1530;
133         struct SERVER_INFO_1533 i1533;
134         struct SERVER_INFO_1534 i1534;
135         struct SERVER_INFO_1535 i1535;
136         struct SERVER_INFO_1536 i1536;
137         struct SERVER_INFO_1537 i1537;
138         struct SERVER_INFO_1538 i1538;
139         struct SERVER_INFO_1539 i1539;
140         struct SERVER_INFO_1540 i1540;
141         struct SERVER_INFO_1541 i1541;
142         struct SERVER_INFO_1542 i1542;
143         struct SERVER_INFO_1543 i1543;
144         struct SERVER_INFO_1544 i1544;
145         struct SERVER_INFO_1545 i1545;
146         struct SERVER_INFO_1546 i1546;
147         struct SERVER_INFO_1547 i1547;
148         struct SERVER_INFO_1548 i1548;
149         struct SERVER_INFO_1549 i1549;
150         struct SERVER_INFO_1550 i1550;
151         struct SERVER_INFO_1552 i1552;
152         struct SERVER_INFO_1553 i1553;
153         struct SERVER_INFO_1554 i1554;
154         struct SERVER_INFO_1555 i1555;
155         struct SERVER_INFO_1556 i1556;
156         struct SERVER_INFO_1557 i1557;
157         struct SERVER_INFO_1560 i1560;
158         struct SERVER_INFO_1561 i1561;
159         struct SERVER_INFO_1562 i1562;
160         struct SERVER_INFO_1563 i1563;
161         struct SERVER_INFO_1564 i1564;
162         struct SERVER_INFO_1565 i1565;
163         struct SERVER_INFO_1566 i1566;
164         struct SERVER_INFO_1567 i1567;
165         struct SERVER_INFO_1568 i1568;
166         struct SERVER_INFO_1569 i1569;
167         struct SERVER_INFO_1570 i1570;
168         struct SERVER_INFO_1571 i1571;
169         struct SERVER_INFO_1572 i1572;
170         struct SERVER_INFO_1573 i1573;
171         struct SERVER_INFO_1574 i1574;
172         struct SERVER_INFO_1575 i1575;
173         struct SERVER_INFO_1576 i1576;
174         struct SERVER_INFO_1577 i1577;
175         struct SERVER_INFO_1578 i1578;
176         struct SERVER_INFO_1579 i1579;
177         struct SERVER_INFO_1580 i1580;
178         struct SERVER_INFO_1581 i1581;
179         struct SERVER_INFO_1582 i1582;
180         struct SERVER_INFO_1583 i1583;
181         struct SERVER_INFO_1584 i1584;
182         struct SERVER_INFO_1585 i1585;
183         struct SERVER_INFO_1586 i1586;
184         struct SERVER_INFO_1587 i1587;
185         struct SERVER_INFO_1588 i1588;
186         struct SERVER_INFO_1590 i1590;
187         struct SERVER_INFO_1591 i1591;
188         struct SERVER_INFO_1592 i1592;
189         struct SERVER_INFO_1593 i1593;
190         struct SERVER_INFO_1594 i1594;
191         struct SERVER_INFO_1595 i1595;
192         struct SERVER_INFO_1596 i1596;
193         struct SERVER_INFO_1597 i1597;
194         struct SERVER_INFO_1598 i1598;
195         struct SERVER_INFO_1599 i1599;
196         struct SERVER_INFO_1600 i1600;
197         struct SERVER_INFO_1601 i1601;
198         struct SERVER_INFO_1602 i1602;
199 #endif
200         uint32_t num_info = 0;
201
202         switch (level) {
203                 case 100:
204                         i100.sv100_platform_id          = i->info100->platform_id;
205                         i100.sv100_name                 = talloc_strdup(mem_ctx, i->info100->server_name);
206
207                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_100, i100,
208                                      (struct SERVER_INFO_100 **)buffer,
209                                      &num_info);
210                         break;
211
212                 case 101:
213                         i101.sv101_platform_id          = i->info101->platform_id;
214                         i101.sv101_name                 = talloc_strdup(mem_ctx, i->info101->server_name);
215                         i101.sv101_version_major        = i->info101->version_major;
216                         i101.sv101_version_minor        = i->info101->version_minor;
217                         i101.sv101_type                 = i->info101->server_type;
218                         i101.sv101_comment              = talloc_strdup(mem_ctx, i->info101->comment);
219
220                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_101, i101,
221                                      (struct SERVER_INFO_101 **)buffer,
222                                      &num_info);
223                         break;
224
225                 case 102:
226                         i102.sv102_platform_id          = i->info102->platform_id;
227                         i102.sv102_name                 = talloc_strdup(mem_ctx, i->info102->server_name);
228                         i102.sv102_version_major        = i->info102->version_major;
229                         i102.sv102_version_minor        = i->info102->version_minor;
230                         i102.sv102_type                 = i->info102->server_type;
231                         i102.sv102_comment              = talloc_strdup(mem_ctx, i->info102->comment);
232                         i102.sv102_users                = i->info102->users;
233                         i102.sv102_disc                 = i->info102->disc;
234                         i102.sv102_hidden               = i->info102->hidden;
235                         i102.sv102_announce             = i->info102->announce;
236                         i102.sv102_anndelta             = i->info102->anndelta;
237                         i102.sv102_licenses             = i->info102->licenses;
238                         i102.sv102_userpath             = talloc_strdup(mem_ctx, i->info102->userpath);
239
240                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_102, i102,
241                                      (struct SERVER_INFO_102 **)buffer,
242                                      &num_info);
243                         break;
244
245                 case 402:
246
247                         i402.sv402_ulist_mtime          = i->info402->ulist_mtime;
248                         i402.sv402_glist_mtime          = i->info402->glist_mtime;
249                         i402.sv402_alist_mtime          = i->info402->alist_mtime;
250                         i402.sv402_alerts               = talloc_strdup(mem_ctx, i->info402->alerts);
251                         i402.sv402_security             = i->info402->security;
252                         i402.sv402_numadmin             = i->info402->numadmin;
253                         i402.sv402_lanmask              = i->info402->lanmask;
254                         i402.sv402_guestacct            = talloc_strdup(mem_ctx, i->info402->guestaccount);
255                         i402.sv402_chdevs               = i->info402->chdevs;
256                         i402.sv402_chdevq               = i->info402->chdevqs;
257                         i402.sv402_chdevjobs            = i->info402->chdevjobs;
258                         i402.sv402_connections          = i->info402->connections;
259                         i402.sv402_shares               = i->info402->shares;
260                         i402.sv402_openfiles            = i->info402->openfiles;
261                         i402.sv402_sessopens            = i->info402->sessopen;
262                         i402.sv402_sessvcs              = i->info402->sesssvc;
263                         i402.sv402_sessreqs             = i->info402->sessreqs;
264                         i402.sv402_opensearch           = i->info402->opensearch;
265                         i402.sv402_activelocks          = i->info402->activelocks;
266                         i402.sv402_numreqbuf            = i->info402->numreqbufs;
267                         i402.sv402_sizreqbuf            = i->info402->sizereqbufs;
268                         i402.sv402_numbigbuf            = i->info402->numbigbufs;
269                         i402.sv402_numfiletasks         = i->info402->numfiletasks;
270                         i402.sv402_alertsched           = i->info402->alertsched;
271                         i402.sv402_erroralert           = i->info402->erroralert;
272                         i402.sv402_logonalert           = i->info402->logonalert;
273                         i402.sv402_accessalert          = i->info402->accessalert;
274                         i402.sv402_diskalert            = i->info402->diskalert;
275                         i402.sv402_netioalert           = i->info402->netioalert;
276                         i402.sv402_maxauditsz           = i->info402->maxaudits;
277                         i402.sv402_srvheuristics        = i->info402->srvheuristics;
278
279                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_402, i402,
280                                      (struct SERVER_INFO_402 **)buffer,
281                                      &num_info);
282                         break;
283
284                 case 403:
285
286                         i403.sv403_ulist_mtime          = i->info403->ulist_mtime;
287                         i403.sv403_glist_mtime          = i->info403->glist_mtime;
288                         i403.sv403_alist_mtime          = i->info403->alist_mtime;
289                         i403.sv403_alerts               = talloc_strdup(mem_ctx, i->info403->alerts);
290                         i403.sv403_security             = i->info403->security;
291                         i403.sv403_numadmin             = i->info403->numadmin;
292                         i403.sv403_lanmask              = i->info403->lanmask;
293                         i403.sv403_guestacct            = talloc_strdup(mem_ctx, i->info403->guestaccount);
294                         i403.sv403_chdevs               = i->info403->chdevs;
295                         i403.sv403_chdevq               = i->info403->chdevqs;
296                         i403.sv403_chdevjobs            = i->info403->chdevjobs;
297                         i403.sv403_connections          = i->info403->connections;
298                         i403.sv403_shares               = i->info403->shares;
299                         i403.sv403_openfiles            = i->info403->openfiles;
300                         i403.sv403_sessopens            = i->info403->sessopen;
301                         i403.sv403_sessvcs              = i->info403->sesssvc;
302                         i403.sv403_sessreqs             = i->info403->sessreqs;
303                         i403.sv403_opensearch           = i->info403->opensearch;
304                         i403.sv403_activelocks          = i->info403->activelocks;
305                         i403.sv403_numreqbuf            = i->info403->numreqbufs;
306                         i403.sv403_sizreqbuf            = i->info403->sizereqbufs;
307                         i403.sv403_numbigbuf            = i->info403->numbigbufs;
308                         i403.sv403_numfiletasks         = i->info403->numfiletasks;
309                         i403.sv403_alertsched           = i->info403->alertsched;
310                         i403.sv403_erroralert           = i->info403->erroralert;
311                         i403.sv403_logonalert           = i->info403->logonalert;
312                         i403.sv403_accessalert          = i->info403->accessalert;
313                         i403.sv403_diskalert            = i->info403->diskalert;
314                         i403.sv403_netioalert           = i->info403->netioalert;
315                         i403.sv403_maxauditsz           = i->info403->maxaudits;
316                         i403.sv403_srvheuristics        = i->info403->srvheuristics;
317                         i403.sv403_auditedevents        = i->info403->auditedevents;
318                         i403.sv403_autoprofile          = i->info403->auditprofile;
319                         i403.sv403_autopath             = talloc_strdup(mem_ctx, i->info403->autopath);
320
321                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_403, i403,
322                                      (struct SERVER_INFO_403 **)buffer,
323                                      &num_info);
324                         break;
325
326                 case 502:
327                         i502.sv502_sessopens            = i->info502->sessopen;
328                         i502.sv502_sessvcs              = i->info502->sesssvc;
329                         i502.sv502_opensearch           = i->info502->opensearch;
330                         i502.sv502_sizreqbuf            = i->info502->sizereqbufs;
331                         i502.sv502_initworkitems        = i->info502->initworkitems;
332                         i502.sv502_maxworkitems         = i->info502->maxworkitems;
333                         i502.sv502_rawworkitems         = i->info502->rawworkitems;
334                         i502.sv502_irpstacksize         = i->info502->irpstacksize;
335                         i502.sv502_maxrawbuflen         = i->info502->maxrawbuflen;
336                         i502.sv502_sessusers            = i->info502->sessusers;
337                         i502.sv502_sessconns            = i->info502->sessconns;
338                         i502.sv502_maxpagedmemoryusage  = i->info502->maxpagedmemoryusage;
339                         i502.sv502_maxnonpagedmemoryusage = i->info502->maxnonpagedmemoryusage;
340                         i502.sv502_enablesoftcompat     = i->info502->enablesoftcompat;
341                         i502.sv502_enableforcedlogoff   = i->info502->enableforcedlogoff;
342                         i502.sv502_timesource           = i->info502->timesource;
343                         i502.sv502_acceptdownlevelapis  = i->info502->acceptdownlevelapis;
344                         i502.sv502_lmannounce           = i->info502->lmannounce;
345
346                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_502, i502,
347                                      (struct SERVER_INFO_502 **)buffer,
348                                      &num_info);
349                         break;
350
351                 case 503:
352                         i503.sv503_sessopens            = i->info503->sessopen;
353                         i503.sv503_sessvcs              = i->info503->sesssvc;
354                         i503.sv503_opensearch           = i->info503->opensearch;
355                         i503.sv503_sizreqbuf            = i->info503->sizereqbufs;
356                         i503.sv503_initworkitems        = i->info503->initworkitems;
357                         i503.sv503_maxworkitems         = i->info503->maxworkitems;
358                         i503.sv503_rawworkitems         = i->info503->rawworkitems;
359                         i503.sv503_irpstacksize         = i->info503->irpstacksize;
360                         i503.sv503_maxrawbuflen         = i->info503->maxrawbuflen;
361                         i503.sv503_sessusers            = i->info503->sessusers;
362                         i503.sv503_sessconns            = i->info503->sessconns;
363                         i503.sv503_maxpagedmemoryusage  = i->info503->maxpagedmemoryusage;
364                         i503.sv503_maxnonpagedmemoryusage = i->info503->maxnonpagedmemoryusage;
365                         i503.sv503_enablesoftcompat     = i->info503->enablesoftcompat;
366                         i503.sv503_enableforcedlogoff   = i->info503->enableforcedlogoff;
367                         i503.sv503_timesource           = i->info503->timesource;
368                         i503.sv503_acceptdownlevelapis  = i->info503->acceptdownlevelapis;
369                         i503.sv503_lmannounce           = i->info503->lmannounce;
370                         i503.sv503_domain               = talloc_strdup(mem_ctx, i->info503->domain);
371                         i503.sv503_maxcopyreadlen       = i->info503->maxcopyreadlen;
372                         i503.sv503_maxcopywritelen      = i->info503->maxcopywritelen;
373                         i503.sv503_minkeepsearch        = i->info503->minkeepsearch;
374                         i503.sv503_maxkeepsearch        = i->info503->maxkeepsearch;
375                         i503.sv503_minkeepcomplsearch   = i->info503->minkeepcomplsearch;
376                         i503.sv503_maxkeepcomplsearch   = i->info503->maxkeepcomplsearch;
377                         i503.sv503_threadcountadd       = i->info503->threadcountadd;
378                         i503.sv503_numblockthreads      = i->info503->numlockthreads;
379                         i503.sv503_scavtimeout          = i->info503->scavtimeout;
380                         i503.sv503_minrcvqueue          = i->info503->minrcvqueue;
381                         i503.sv503_minfreeworkitems     = i->info503->minfreeworkitems;
382                         i503.sv503_xactmemsize          = i->info503->xactmemsize;
383                         i503.sv503_threadpriority       = i->info503->threadpriority;
384                         i503.sv503_maxmpxct             = i->info503->maxmpxct;
385                         i503.sv503_oplockbreakwait      = i->info503->oplockbreakwait;
386                         i503.sv503_oplockbreakresponsewait = i->info503->oplockbreakresponsewait;
387                         i503.sv503_enableoplocks        = i->info503->enableoplocks;
388                         i503.sv503_enableoplockforceclose = i->info503->enableoplockforceclose;
389                         i503.sv503_enablefcbopens       = i->info503->enablefcbopens;
390                         i503.sv503_enableraw            = i->info503->enableraw;
391                         i503.sv503_enablesharednetdrives = i->info503->enablesharednetdrives;
392                         i503.sv503_minfreeconnections   = i->info503->minfreeconnections;
393                         i503.sv503_maxfreeconnections   = i->info503->maxfreeconnections;
394
395                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_503, i503,
396                                      (struct SERVER_INFO_503 **)buffer,
397                                      &num_info);
398                         break;
399
400                 case 599:
401                         i599.sv599_sessopens            = i->info599->sessopen;
402                         i599.sv599_sessvcs              = i->info599->sesssvc;
403                         i599.sv599_opensearch           = i->info599->opensearch;
404                         i599.sv599_sizreqbuf            = i->info599->sizereqbufs;
405                         i599.sv599_initworkitems        = i->info599->initworkitems;
406                         i599.sv599_maxworkitems         = i->info599->maxworkitems;
407                         i599.sv599_rawworkitems         = i->info599->rawworkitems;
408                         i599.sv599_irpstacksize         = i->info599->irpstacksize;
409                         i599.sv599_maxrawbuflen         = i->info599->maxrawbuflen;
410                         i599.sv599_sessusers            = i->info599->sessusers;
411                         i599.sv599_sessconns            = i->info599->sessconns;
412                         i599.sv599_maxpagedmemoryusage  = i->info599->maxpagedmemoryusage;
413                         i599.sv599_maxnonpagedmemoryusage = i->info599->maxnonpagedmemoryusage;
414                         i599.sv599_enablesoftcompat     = i->info599->enablesoftcompat;
415                         i599.sv599_enableforcedlogoff   = i->info599->enableforcedlogoff;
416                         i599.sv599_timesource           = i->info599->timesource;
417                         i599.sv599_acceptdownlevelapis  = i->info599->acceptdownlevelapis;
418                         i599.sv599_lmannounce           = i->info599->lmannounce;
419                         i599.sv599_domain               = talloc_strdup(mem_ctx, i->info599->domain);
420                         i599.sv599_maxcopyreadlen       = i->info599->maxcopyreadlen;
421                         i599.sv599_maxcopywritelen      = i->info599->maxcopywritelen;
422                         i599.sv599_minkeepsearch        = i->info599->minkeepsearch;
423                         i599.sv599_maxkeepsearch        = 0; /* ?? */
424                         i599.sv599_minkeepcomplsearch   = i->info599->minkeepcomplsearch;
425                         i599.sv599_maxkeepcomplsearch   = i->info599->maxkeepcomplsearch;
426                         i599.sv599_threadcountadd       = i->info599->threadcountadd;
427                         i599.sv599_numblockthreads      = i->info599->numlockthreads; /* typo ? */
428                         i599.sv599_scavtimeout          = i->info599->scavtimeout;
429                         i599.sv599_minrcvqueue          = i->info599->minrcvqueue;
430                         i599.sv599_minfreeworkitems     = i->info599->minfreeworkitems;
431                         i599.sv599_xactmemsize          = i->info599->xactmemsize;
432                         i599.sv599_threadpriority       = i->info599->threadpriority;
433                         i599.sv599_maxmpxct             = i->info599->maxmpxct;
434                         i599.sv599_oplockbreakwait      = i->info599->oplockbreakwait;
435                         i599.sv599_oplockbreakresponsewait = i->info599->oplockbreakresponsewait;
436                         i599.sv599_enableoplocks        = i->info599->enableoplocks;
437                         i599.sv599_enableoplockforceclose = i->info599->enableoplockforceclose;
438                         i599.sv599_enablefcbopens       = i->info599->enablefcbopens;
439                         i599.sv599_enableraw            = i->info599->enableraw;
440                         i599.sv599_enablesharednetdrives = i->info599->enablesharednetdrives;
441                         i599.sv599_minfreeconnections   = i->info599->minfreeconnections;
442                         i599.sv599_maxfreeconnections   = i->info599->maxfreeconnections;
443                         i599.sv599_initsesstable        = i->info599->initsesstable;
444                         i599.sv599_initconntable        = i->info599->initconntable;
445                         i599.sv599_initfiletable        = i->info599->initfiletable;
446                         i599.sv599_initsearchtable      = i->info599->initsearchtable;
447                         i599.sv599_alertschedule        = i->info599->alertsched;
448                         i599.sv599_errorthreshold       = i->info599->errortreshold;
449                         i599.sv599_networkerrorthreshold = i->info599->networkerrortreshold;
450                         i599.sv599_diskspacethreshold   = i->info599->diskspacetreshold;
451                         i599.sv599_reserved             = i->info599->reserved;
452                         i599.sv599_maxlinkdelay         = i->info599->maxlinkdelay;
453                         i599.sv599_minlinkthroughput    = i->info599->minlinkthroughput;
454                         i599.sv599_linkinfovalidtime    = i->info599->linkinfovalidtime;
455                         i599.sv599_scavqosinfoupdatetime = i->info599->scavqosinfoupdatetime;
456                         i599.sv599_maxworkitemidletime  = i->info599->maxworkitemidletime;
457
458                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_599, i599,
459                                      (struct SERVER_INFO_599 **)buffer,
460                                      &num_info);
461                         break;
462
463                 case 1005:
464                         i1005.sv1005_comment            = talloc_strdup(mem_ctx, i->info1005->comment);
465
466                         ADD_TO_ARRAY(mem_ctx, struct SERVER_INFO_1005, i1005,
467                                      (struct SERVER_INFO_1005 **)buffer,
468                                      &num_info);
469                         break;
470                 default:
471                         return NT_STATUS_NOT_SUPPORTED;
472         }
473
474         return NT_STATUS_OK;
475 }
476
477 /****************************************************************
478 ****************************************************************/
479
480 WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
481                           struct NetServerGetInfo *r)
482 {
483         struct rpc_pipe_client *pipe_cli = NULL;
484         NTSTATUS status;
485         WERROR werr;
486         union srvsvc_NetSrvInfo info;
487
488         if (!r->out.buffer) {
489                 return WERR_INVALID_PARAM;
490         }
491
492         switch (r->in.level) {
493                 case 100:
494                 case 101:
495                 case 102:
496                 case 402:
497                 case 502:
498                 case 503:
499                 case 1005:
500                         break;
501                 default:
502                         return WERR_UNKNOWN_LEVEL;
503         }
504
505         werr = libnetapi_open_pipe(ctx, r->in.server_name,
506                                    &ndr_table_srvsvc.syntax_id,
507                                    &pipe_cli);
508         if (!W_ERROR_IS_OK(werr)) {
509                 goto done;
510         }
511
512         status = rpccli_srvsvc_NetSrvGetInfo(pipe_cli, ctx,
513                                              r->in.server_name,
514                                              r->in.level,
515                                              &info,
516                                              &werr);
517         if (!NT_STATUS_IS_OK(status)) {
518                 werr = ntstatus_to_werror(status);
519                 goto done;
520         }
521
522         status = map_server_info_to_SERVER_INFO_buffer(ctx, r->in.level, &info,
523                                                        r->out.buffer);
524         if (!NT_STATUS_IS_OK(status)) {
525                 werr = ntstatus_to_werror(status);
526                 goto done;
527         }
528
529  done:
530         return werr;
531 }
532
533 /****************************************************************
534 ****************************************************************/
535
536 static WERROR NetServerSetInfo_l_1005(struct libnetapi_ctx *ctx,
537                                       struct NetServerSetInfo *r)
538 {
539         WERROR werr;
540         struct smbconf_ctx *conf_ctx;
541         struct srvsvc_NetSrvInfo1005 *info1005;
542
543         if (!r->in.buffer) {
544                 *r->out.parm_error = 1005; /* sure here ? */
545                 return WERR_INVALID_PARAM;
546         }
547
548         info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer;
549
550         if (!info1005->comment) {
551                 *r->out.parm_error = 1005;
552                 return WERR_INVALID_PARAM;
553         }
554
555         if (!lp_config_backend_is_registry()) {
556                 libnetapi_set_error_string(ctx,
557                         "Configuration manipulation requested but not "
558                         "supported by backend");
559                 return WERR_NOT_SUPPORTED;
560         }
561
562         werr = smbconf_init_reg(ctx, &conf_ctx, NULL);
563         if (!W_ERROR_IS_OK(werr)) {
564                 goto done;
565         }
566
567         werr = smbconf_set_global_parameter(conf_ctx, "server string",
568                                             info1005->comment);
569
570  done:
571         smbconf_shutdown(conf_ctx);
572         return werr;
573 }
574
575 /****************************************************************
576 ****************************************************************/
577
578 WERROR NetServerSetInfo_l(struct libnetapi_ctx *ctx,
579                           struct NetServerSetInfo *r)
580 {
581         switch (r->in.level) {
582                 case 1005:
583                         return NetServerSetInfo_l_1005(ctx, r);
584                 default:
585                         break;
586         }
587
588         return WERR_UNKNOWN_LEVEL;
589 }
590
591 /****************************************************************
592 ****************************************************************/
593
594 WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
595                           struct NetServerSetInfo *r)
596 {
597         struct rpc_pipe_client *pipe_cli = NULL;
598         NTSTATUS status;
599         WERROR werr;
600         union srvsvc_NetSrvInfo info;
601
602         werr = libnetapi_open_pipe(ctx, r->in.server_name,
603                                    &ndr_table_srvsvc.syntax_id,
604                                    &pipe_cli);
605         if (!W_ERROR_IS_OK(werr)) {
606                 goto done;
607         }
608
609         switch (r->in.level) {
610                 case 1005:
611                         info.info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer;
612                         break;
613                 default:
614                         werr = WERR_NOT_SUPPORTED;
615                         goto done;
616         }
617
618         status = rpccli_srvsvc_NetSrvSetInfo(pipe_cli, ctx,
619                                              r->in.server_name,
620                                              r->in.level,
621                                              &info,
622                                              r->out.parm_error,
623                                              &werr);
624         if (!NT_STATUS_IS_OK(status)) {
625                 werr = ntstatus_to_werror(status);
626                 goto done;
627         }
628
629  done:
630         return werr;
631 }
632
633 /****************************************************************
634 ****************************************************************/
635
636 WERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx,
637                       struct NetRemoteTOD *r)
638 {
639         struct rpc_pipe_client *pipe_cli = NULL;
640         NTSTATUS status;
641         WERROR werr;
642         struct srvsvc_NetRemoteTODInfo *info = NULL;
643
644         werr = libnetapi_open_pipe(ctx, r->in.server_name,
645                                    &ndr_table_srvsvc.syntax_id,
646                                    &pipe_cli);
647         if (!W_ERROR_IS_OK(werr)) {
648                 goto done;
649         }
650
651         status = rpccli_srvsvc_NetRemoteTOD(pipe_cli, ctx,
652                                             r->in.server_name,
653                                             &info,
654                                             &werr);
655         if (!NT_STATUS_IS_OK(status)) {
656                 werr = ntstatus_to_werror(status);
657                 goto done;
658         }
659
660         *r->out.buffer = (uint8_t *)talloc_memdup(ctx, info,
661                           sizeof(struct srvsvc_NetRemoteTODInfo));
662         W_ERROR_HAVE_NO_MEMORY(*r->out.buffer);
663
664  done:
665         return werr;
666 }
667
668 /****************************************************************
669 ****************************************************************/
670
671 WERROR NetRemoteTOD_l(struct libnetapi_ctx *ctx,
672                       struct NetRemoteTOD *r)
673 {
674         LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetRemoteTOD);
675 }
676