1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
|
/*
* Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
*
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Gerald (Jerry) Carter 2006.
* Copyright (C) Guenther Deschner 2007-2008.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/* This is the implementation of the wks interface. */
#include "includes.h"
#include "ntdomain.h"
#include "librpc/gen_ndr/libnet_join.h"
#include "libnet/libnet_join.h"
#include "../libcli/auth/libcli_auth.h"
#include "../librpc/gen_ndr/srv_wkssvc.h"
#include "../libcli/security/security.h"
#include "session.h"
#include "smbd/smbd.h"
#include "auth.h"
#include "krb5_env.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
struct dom_usr {
char *name;
char *domain;
time_t login_time;
};
#ifdef HAVE_GETUTXENT
#include <utmpx.h>
struct usrinfo {
char *name;
struct timeval login_time;
};
static int usr_info_cmp(const struct usrinfo *usr1, const struct usrinfo *usr2)
{
/* Called from qsort to compare two users in a usrinfo_t array for
* sorting by login time. Return >0 if usr1 login time was later than
* usr2 login time, <0 if it was earlier */
return timeval_compare(&usr1->login_time, &usr2->login_time);
}
/*******************************************************************
Get a list of the names of all users logged into this machine
********************************************************************/
static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
{
char **users;
int i, num_users = 0;
struct usrinfo *usr_infos = NULL;
struct utmpx *u;
while ((u = getutxent()) != NULL) {
struct usrinfo *tmp;
if (u->ut_type != USER_PROCESS) {
continue;
}
for (i = 0; i < num_users; i++) {
/* getutxent can return multiple user entries for the
* same user, so ignore any dups */
if (strcmp(u->ut_user, usr_infos[i].name) == 0) {
break;
}
}
if (i < num_users) {
continue;
}
tmp = talloc_realloc(mem_ctx, usr_infos, struct usrinfo,
num_users+1);
if (tmp == NULL) {
TALLOC_FREE(tmp);
endutxent();
return NULL;
}
usr_infos = tmp;
usr_infos[num_users].name = talloc_strdup(usr_infos,
u->ut_user);
if (usr_infos[num_users].name == NULL) {
TALLOC_FREE(usr_infos);
endutxent();
return NULL;
}
usr_infos[num_users].login_time.tv_sec = u->ut_tv.tv_sec;
usr_infos[num_users].login_time.tv_usec = u->ut_tv.tv_usec;
num_users += 1;
}
/* Sort the user list by time, oldest first */
TYPESAFE_QSORT(usr_infos, num_users, usr_info_cmp);
users = (char**)talloc_array(mem_ctx, char*, num_users);
if (users) {
for (i = 0; i < num_users; i++) {
users[i] = talloc_move(users, &usr_infos[i].name);
}
}
TALLOC_FREE(usr_infos);
endutxent();
errno = 0;
return users;
}
#else
static char **get_logged_on_userlist(TALLOC_CTX *mem_ctx)
{
return NULL;
}
#endif
static int dom_user_cmp(const struct dom_usr *usr1, const struct dom_usr *usr2)
{
/* Called from qsort to compare two domain users in a dom_usr_t array
* for sorting by login time. Return >0 if usr1 login time was later
* than usr2 login time, <0 if it was earlier */
return (usr1->login_time - usr2->login_time);
}
/*******************************************************************
Get a list of the names of all users of this machine who are
logged into the domain.
This should return a list of the users on this machine who are
logged into the domain (i.e. have been authenticated by the domain's
password server) but that doesn't fit well with the normal Samba
scenario where accesses out to the domain are made through smbclient
with each such session individually authenticated. So about the best
we can do currently is to list sessions of local users connected to
this server, which means that to get themself included in the list a
local user must create a session to the local samba server by running:
smbclient \\\\localhost\\share
FIXME: find a better way to get local users logged into the domain
in this list.
********************************************************************/
static struct dom_usr *get_domain_userlist(TALLOC_CTX *mem_ctx)
{
struct sessionid *session_list = NULL;
char *machine_name, *p, *nm;
const char *sep;
struct dom_usr *users, *tmp;
int i, num_users, num_sessions;
sep = lp_winbind_separator();
if (!sep) {
sep = "\\";
}
num_sessions = list_sessions(mem_ctx, &session_list);
if (num_sessions == 0) {
errno = 0;
return NULL;
}
users = talloc_array(mem_ctx, struct dom_usr, num_sessions);
if (users == NULL) {
TALLOC_FREE(session_list);
return NULL;
}
for (i=num_users=0; i<num_sessions; i++) {
if (!session_list[i].username
|| !session_list[i].remote_machine) {
continue;
}
p = strpbrk(session_list[i].remote_machine, "./");
if (p) {
*p = '\0';
}
machine_name = talloc_asprintf_strupper_m(
users, "%s", session_list[i].remote_machine);
if (machine_name == NULL) {
DEBUG(10, ("talloc_asprintf failed\n"));
continue;
}
if (strcmp(machine_name, lp_netbios_name()) == 0) {
p = session_list[i].username;
nm = strstr(p, sep);
if (nm) {
/*
* "domain+name" format so split domain and
* name components
*/
*nm = '\0';
nm += strlen(sep);
users[num_users].domain =
talloc_asprintf_strupper_m(users,
"%s", p);
users[num_users].name = talloc_strdup(users,
nm);
} else {
/*
* Simple user name so get domain from smb.conf
*/
users[num_users].domain =
talloc_strdup(users, lp_workgroup());
users[num_users].name = talloc_strdup(users,
p);
}
users[num_users].login_time =
session_list[i].connect_start;
num_users++;
}
TALLOC_FREE(machine_name);
}
TALLOC_FREE(session_list);
tmp = talloc_realloc(mem_ctx, users, struct dom_usr, num_users);
if (tmp == NULL) {
return NULL;
}
users = tmp;
/* Sort the user list by time, oldest first */
TYPESAFE_QSORT(users, num_users, dom_user_cmp);
errno = 0;
return users;
}
/*******************************************************************
RPC Workstation Service request NetWkstaGetInfo with level 100.
Returns to the requester:
- The machine name.
- The smb version number
- The domain name.
Returns a filled in wkssvc_NetWkstaInfo100 struct.
********************************************************************/
static struct wkssvc_NetWkstaInfo100 *create_wks_info_100(TALLOC_CTX *mem_ctx)
{
struct wkssvc_NetWkstaInfo100 *info100;
info100 = talloc(mem_ctx, struct wkssvc_NetWkstaInfo100);
if (info100 == NULL) {
return NULL;
}
info100->platform_id = PLATFORM_ID_NT; /* unknown */
info100->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
info100->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info100->server_name = talloc_asprintf_strupper_m(
info100, "%s", lp_netbios_name());
info100->domain_name = talloc_asprintf_strupper_m(
info100, "%s", lp_workgroup());
return info100;
}
/*******************************************************************
RPC Workstation Service request NetWkstaGetInfo with level 101.
Returns to the requester:
- As per NetWkstaGetInfo with level 100, plus:
- The LANMAN directory path (not currently supported).
Returns a filled in wkssvc_NetWkstaInfo101 struct.
********************************************************************/
static struct wkssvc_NetWkstaInfo101 *create_wks_info_101(TALLOC_CTX *mem_ctx)
{
struct wkssvc_NetWkstaInfo101 *info101;
info101 = talloc(mem_ctx, struct wkssvc_NetWkstaInfo101);
if (info101 == NULL) {
return NULL;
}
info101->platform_id = PLATFORM_ID_NT; /* unknown */
info101->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
info101->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info101->server_name = talloc_asprintf_strupper_m(
info101, "%s", lp_netbios_name());
info101->domain_name = talloc_asprintf_strupper_m(
info101, "%s", lp_workgroup());
info101->lan_root = "";
return info101;
}
/*******************************************************************
RPC Workstation Service request NetWkstaGetInfo with level 102.
Returns to the requester:
- As per NetWkstaGetInfo with level 101, plus:
- The number of logged in users.
Returns a filled in wkssvc_NetWkstaInfo102 struct.
********************************************************************/
static struct wkssvc_NetWkstaInfo102 *create_wks_info_102(TALLOC_CTX *mem_ctx)
{
struct wkssvc_NetWkstaInfo102 *info102;
char **users;
info102 = talloc(mem_ctx, struct wkssvc_NetWkstaInfo102);
if (info102 == NULL) {
return NULL;
}
info102->platform_id = PLATFORM_ID_NT; /* unknown */
info102->version_major = SAMBA_MAJOR_NBT_ANNOUNCE_VERSION;
info102->version_minor = SAMBA_MINOR_NBT_ANNOUNCE_VERSION;
info102->server_name = talloc_asprintf_strupper_m(
info102, "%s", lp_netbios_name());
info102->domain_name = talloc_asprintf_strupper_m(
info102, "%s", lp_workgroup());
info102->lan_root = "";
users = get_logged_on_userlist(talloc_tos());
info102->logged_on_users = talloc_array_length(users);
TALLOC_FREE(users);
return info102;
}
/********************************************************************
Handling for RPC Workstation Service request NetWkstaGetInfo
********************************************************************/
WERROR _wkssvc_NetWkstaGetInfo(struct pipes_struct *p,
struct wkssvc_NetWkstaGetInfo *r)
{
switch (r->in.level) {
case 100:
/* Level 100 can be allowed from anyone including anonymous
* so no access checks are needed for this case */
r->out.info->info100 = create_wks_info_100(p->mem_ctx);
if (r->out.info->info100 == NULL) {
return WERR_NOMEM;
}
break;
case 101:
/* Level 101 can be allowed from any logged in user */
if (!nt_token_check_sid(&global_sid_Authenticated_Users,
p->session_info->security_token)) {
DEBUG(1,("User not allowed for NetWkstaGetInfo level "
"101\n"));
DEBUGADD(3,(" - does not have sid for Authenticated "
"Users %s:\n",
sid_string_dbg(
&global_sid_Authenticated_Users)));
security_token_debug(DBGC_CLASS, 3,
p->session_info->security_token);
return WERR_ACCESS_DENIED;
}
r->out.info->info101 = create_wks_info_101(p->mem_ctx);
if (r->out.info->info101 == NULL) {
return WERR_NOMEM;
}
break;
case 102:
/* Level 102 Should only be allowed from a domain administrator */
if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
p->session_info->security_token)) {
DEBUG(1,("User not allowed for NetWkstaGetInfo level "
"102\n"));
DEBUGADD(3,(" - does not have sid for Administrators "
"group %s, sids are:\n",
sid_string_dbg(&global_sid_Builtin_Administrators)));
security_token_debug(DBGC_CLASS, 3,
p->session_info->security_token);
return WERR_ACCESS_DENIED;
}
r->out.info->info102 = create_wks_info_102(p->mem_ctx);
if (r->out.info->info102 == NULL) {
return WERR_NOMEM;
}
break;
default:
return WERR_UNKNOWN_LEVEL;
}
return WERR_OK;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetWkstaSetInfo(struct pipes_struct *p,
struct wkssvc_NetWkstaSetInfo *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
RPC Workstation Service request NetWkstaEnumUsers with level 0:
Returns to the requester:
- the user names of the logged in users.
Returns a filled in wkssvc_NetWkstaEnumUsersCtr0 struct.
********************************************************************/
static struct wkssvc_NetWkstaEnumUsersCtr0 *create_enum_users0(
TALLOC_CTX *mem_ctx)
{
struct wkssvc_NetWkstaEnumUsersCtr0 *ctr0;
char **users;
int i, num_users;
ctr0 = talloc(mem_ctx, struct wkssvc_NetWkstaEnumUsersCtr0);
if (ctr0 == NULL) {
return NULL;
}
users = get_logged_on_userlist(talloc_tos());
if (users == NULL && errno != 0) {
DEBUG(1,("get_logged_on_userlist error %d: %s\n",
errno, strerror(errno)));
TALLOC_FREE(ctr0);
return NULL;
}
num_users = talloc_array_length(users);
ctr0->entries_read = num_users;
ctr0->user0 = talloc_array(ctr0, struct wkssvc_NetrWkstaUserInfo0,
num_users);
if (ctr0->user0 == NULL) {
TALLOC_FREE(ctr0);
TALLOC_FREE(users);
return NULL;
}
for (i=0; i<num_users; i++) {
ctr0->user0[i].user_name = talloc_move(ctr0->user0, &users[i]);
}
TALLOC_FREE(users);
return ctr0;
}
/********************************************************************
RPC Workstation Service request NetWkstaEnumUsers with level 1.
Returns to the requester:
- the user names of the logged in users,
- the domain or machine each is logged into,
- the password server that was used to authenticate each,
- other domains each user is logged into (not currently supported).
Returns a filled in wkssvc_NetWkstaEnumUsersCtr1 struct.
********************************************************************/
static struct wkssvc_NetWkstaEnumUsersCtr1 *create_enum_users1(
TALLOC_CTX *mem_ctx)
{
struct wkssvc_NetWkstaEnumUsersCtr1 *ctr1;
char **users;
struct dom_usr *dom_users;
const char *pwd_server;
char *pwd_tmp;
int i, j, num_users, num_dom_users;
ctr1 = talloc(mem_ctx, struct wkssvc_NetWkstaEnumUsersCtr1);
if (ctr1 == NULL) {
return NULL;
}
users = get_logged_on_userlist(talloc_tos());
if (users == NULL && errno != 0) {
DEBUG(1,("get_logged_on_userlist error %d: %s\n",
errno, strerror(errno)));
TALLOC_FREE(ctr1);
return NULL;
}
num_users = talloc_array_length(users);
dom_users = get_domain_userlist(talloc_tos());
if (dom_users == NULL && errno != 0) {
TALLOC_FREE(ctr1);
TALLOC_FREE(users);
return NULL;
}
num_dom_users = talloc_array_length(dom_users);
ctr1->user1 = talloc_array(ctr1, struct wkssvc_NetrWkstaUserInfo1,
num_users+num_dom_users);
if (ctr1->user1 == NULL) {
TALLOC_FREE(ctr1);
TALLOC_FREE(users);
TALLOC_FREE(dom_users);
return NULL;
}
pwd_server = "";
if ((pwd_tmp = talloc_strdup(ctr1->user1, lp_passwordserver()))) {
/* The configured password server is a full DNS name but
* for the logon server we need to return just the first
* component (machine name) of it in upper-case */
char *p = strchr(pwd_tmp, '.');
if (p) {
*p = '\0';
} else {
p = pwd_tmp + strlen(pwd_tmp);
}
while (--p >= pwd_tmp) {
*p = toupper(*p);
}
pwd_server = pwd_tmp;
}
/* Put in local users first */
for (i=0; i<num_users; i++) {
ctr1->user1[i].user_name = talloc_move(ctr1->user1, &users[i]);
/* For a local user the domain name and logon server are
* both returned as the local machine's NetBIOS name */
ctr1->user1[i].logon_domain = ctr1->user1[i].logon_server =
talloc_asprintf_strupper_m(ctr1->user1, "%s", lp_netbios_name());
ctr1->user1[i].other_domains = NULL; /* Maybe in future? */
}
/* Now domain users */
for (j=0; j<num_dom_users; j++) {
ctr1->user1[i].user_name =
talloc_strdup(ctr1->user1, dom_users[j].name);
ctr1->user1[i].logon_domain =
talloc_strdup(ctr1->user1, dom_users[j].domain);
ctr1->user1[i].logon_server = pwd_server;
ctr1->user1[i++].other_domains = NULL; /* Maybe in future? */
}
ctr1->entries_read = i;
TALLOC_FREE(users);
TALLOC_FREE(dom_users);
return ctr1;
}
/********************************************************************
Handling for RPC Workstation Service request NetWkstaEnumUsers
(a.k.a Windows NetWkstaUserEnum)
********************************************************************/
WERROR _wkssvc_NetWkstaEnumUsers(struct pipes_struct *p,
struct wkssvc_NetWkstaEnumUsers *r)
{
/* This with any level should only be allowed from a domain administrator */
if (!nt_token_check_sid(&global_sid_Builtin_Administrators,
p->session_info->security_token)) {
DEBUG(1,("User not allowed for NetWkstaEnumUsers\n"));
DEBUGADD(3,(" - does not have sid for Administrators group "
"%s\n", sid_string_dbg(
&global_sid_Builtin_Administrators)));
security_token_debug(DBGC_CLASS, 3, p->session_info->security_token);
return WERR_ACCESS_DENIED;
}
switch (r->in.info->level) {
case 0:
r->out.info->ctr.user0 = create_enum_users0(p->mem_ctx);
if (r->out.info->ctr.user0 == NULL) {
return WERR_NOMEM;
}
r->out.info->level = r->in.info->level;
*r->out.entries_read = r->out.info->ctr.user0->entries_read;
*r->out.resume_handle = 0;
break;
case 1:
r->out.info->ctr.user1 = create_enum_users1(p->mem_ctx);
if (r->out.info->ctr.user1 == NULL) {
return WERR_NOMEM;
}
r->out.info->level = r->in.info->level;
*r->out.entries_read = r->out.info->ctr.user1->entries_read;
*r->out.resume_handle = 0;
break;
default:
return WERR_UNKNOWN_LEVEL;
}
return WERR_OK;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrWkstaUserGetInfo(struct pipes_struct *p,
struct wkssvc_NetrWkstaUserGetInfo *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrWkstaUserSetInfo(struct pipes_struct *p,
struct wkssvc_NetrWkstaUserSetInfo *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetWkstaTransportEnum(struct pipes_struct *p,
struct wkssvc_NetWkstaTransportEnum *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrWkstaTransportAdd(struct pipes_struct *p,
struct wkssvc_NetrWkstaTransportAdd *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrWkstaTransportDel(struct pipes_struct *p,
struct wkssvc_NetrWkstaTransportDel *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrUseAdd(struct pipes_struct *p,
struct wkssvc_NetrUseAdd *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrUseGetInfo(struct pipes_struct *p,
struct wkssvc_NetrUseGetInfo *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrUseDel(struct pipes_struct *p,
struct wkssvc_NetrUseDel *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrUseEnum(struct pipes_struct *p,
struct wkssvc_NetrUseEnum *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrMessageBufferSend(struct pipes_struct *p,
struct wkssvc_NetrMessageBufferSend *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrWorkstationStatisticsGet(struct pipes_struct *p,
struct wkssvc_NetrWorkstationStatisticsGet *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrLogonDomainNameAdd(struct pipes_struct *p,
struct wkssvc_NetrLogonDomainNameAdd *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrLogonDomainNameDel(struct pipes_struct *p,
struct wkssvc_NetrLogonDomainNameDel *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrJoinDomain(struct pipes_struct *p,
struct wkssvc_NetrJoinDomain *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrUnjoinDomain(struct pipes_struct *p,
struct wkssvc_NetrUnjoinDomain *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrRenameMachineInDomain(struct pipes_struct *p,
struct wkssvc_NetrRenameMachineInDomain *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrValidateName(struct pipes_struct *p,
struct wkssvc_NetrValidateName *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrGetJoinInformation(struct pipes_struct *p,
struct wkssvc_NetrGetJoinInformation *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrGetJoinableOus(struct pipes_struct *p,
struct wkssvc_NetrGetJoinableOus *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
_wkssvc_NetrJoinDomain2
********************************************************************/
WERROR _wkssvc_NetrJoinDomain2(struct pipes_struct *p,
struct wkssvc_NetrJoinDomain2 *r)
{
struct libnet_JoinCtx *j = NULL;
char *cleartext_pwd = NULL;
char *admin_domain = NULL;
char *admin_account = NULL;
WERROR werr;
struct security_token *token = p->session_info->security_token;
NTSTATUS status;
DATA_BLOB session_key;
if (!r->in.domain_name) {
return WERR_INVALID_PARAM;
}
if (!r->in.admin_account || !r->in.encrypted_password) {
return WERR_INVALID_PARAM;
}
if (!security_token_has_privilege(token, SEC_PRIV_MACHINE_ACCOUNT) &&
!nt_token_check_domain_rid(token, DOMAIN_RID_ADMINS) &&
!nt_token_check_sid(&global_sid_Builtin_Administrators, token)) {
DEBUG(5,("_wkssvc_NetrJoinDomain2: account doesn't have "
"sufficient privileges\n"));
return WERR_ACCESS_DENIED;
}
if ((r->in.join_flags & WKSSVC_JOIN_FLAGS_MACHINE_PWD_PASSED) ||
(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) {
return WERR_NOT_SUPPORTED;
}
status = session_extract_session_key(p->session_info,
&session_key,
KEY_USE_16BYTES);
if(!NT_STATUS_IS_OK(status)) {
DEBUG(5,("_wkssvc_NetrJoinDomain2: no session key %s\n",
nt_errstr(status)));
return WERR_NO_USER_SESSION_KEY;
}
werr = decode_wkssvc_join_password_buffer(
p->mem_ctx, r->in.encrypted_password,
&session_key, &cleartext_pwd);
if (!W_ERROR_IS_OK(werr)) {
return werr;
}
split_domain_user(p->mem_ctx,
r->in.admin_account,
&admin_domain,
&admin_account);
werr = libnet_init_JoinCtx(p->mem_ctx, &j);
if (!W_ERROR_IS_OK(werr)) {
return werr;
}
j->in.domain_name = r->in.domain_name;
j->in.account_ou = r->in.account_ou;
j->in.join_flags = r->in.join_flags;
j->in.admin_account = admin_account;
j->in.admin_password = cleartext_pwd;
j->in.debug = true;
j->in.modify_config = lp_config_backend_is_registry();
j->in.msg_ctx = p->msg_ctx;
become_root();
setenv(KRB5_ENV_CCNAME, "MEMORY:_wkssvc_NetrJoinDomain2", 1);
werr = libnet_Join(p->mem_ctx, j);
unsetenv(KRB5_ENV_CCNAME);
unbecome_root();
if (!W_ERROR_IS_OK(werr)) {
DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join failed with: %s\n",
j->out.error_string ? j->out.error_string :
win_errstr(werr)));
}
TALLOC_FREE(j);
return werr;
}
/********************************************************************
_wkssvc_NetrUnjoinDomain2
********************************************************************/
WERROR _wkssvc_NetrUnjoinDomain2(struct pipes_struct *p,
struct wkssvc_NetrUnjoinDomain2 *r)
{
struct libnet_UnjoinCtx *u = NULL;
char *cleartext_pwd = NULL;
char *admin_domain = NULL;
char *admin_account = NULL;
WERROR werr;
struct security_token *token = p->session_info->security_token;
NTSTATUS status;
DATA_BLOB session_key;
if (!r->in.account || !r->in.encrypted_password) {
return WERR_INVALID_PARAM;
}
if (!security_token_has_privilege(token, SEC_PRIV_MACHINE_ACCOUNT) &&
!nt_token_check_domain_rid(token, DOMAIN_RID_ADMINS) &&
!nt_token_check_sid(&global_sid_Builtin_Administrators, token)) {
DEBUG(5,("_wkssvc_NetrUnjoinDomain2: account doesn't have "
"sufficient privileges\n"));
return WERR_ACCESS_DENIED;
}
status = session_extract_session_key(p->session_info,
&session_key,
KEY_USE_16BYTES);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5,("_wkssvc_NetrUnjoinDomain2: no session key %s\n",
nt_errstr(status)));
return WERR_NO_USER_SESSION_KEY;
}
werr = decode_wkssvc_join_password_buffer(
p->mem_ctx, r->in.encrypted_password,
&session_key, &cleartext_pwd);
if (!W_ERROR_IS_OK(werr)) {
return werr;
}
split_domain_user(p->mem_ctx,
r->in.account,
&admin_domain,
&admin_account);
werr = libnet_init_UnjoinCtx(p->mem_ctx, &u);
if (!W_ERROR_IS_OK(werr)) {
return werr;
}
u->in.domain_name = lp_realm();
u->in.unjoin_flags = r->in.unjoin_flags |
WKSSVC_JOIN_FLAGS_JOIN_TYPE;
u->in.admin_account = admin_account;
u->in.admin_password = cleartext_pwd;
u->in.debug = true;
u->in.modify_config = lp_config_backend_is_registry();
u->in.msg_ctx = p->msg_ctx;
become_root();
setenv(KRB5_ENV_CCNAME, "MEMORY:_wkssvc_NetrUnjoinDomain2", 1);
werr = libnet_Unjoin(p->mem_ctx, u);
unsetenv(KRB5_ENV_CCNAME);
unbecome_root();
if (!W_ERROR_IS_OK(werr)) {
DEBUG(5,("_wkssvc_NetrUnjoinDomain2: libnet_Unjoin failed with: %s\n",
u->out.error_string ? u->out.error_string :
win_errstr(werr)));
}
TALLOC_FREE(u);
return werr;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrRenameMachineInDomain2(struct pipes_struct *p,
struct wkssvc_NetrRenameMachineInDomain2 *r)
{
/* for now just return not supported */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrValidateName2(struct pipes_struct *p,
struct wkssvc_NetrValidateName2 *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrGetJoinableOus2(struct pipes_struct *p,
struct wkssvc_NetrGetJoinableOus2 *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrAddAlternateComputerName(struct pipes_struct *p,
struct wkssvc_NetrAddAlternateComputerName *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrRemoveAlternateComputerName(struct pipes_struct *p,
struct wkssvc_NetrRemoveAlternateComputerName *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrSetPrimaryComputername(struct pipes_struct *p,
struct wkssvc_NetrSetPrimaryComputername *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
WERROR _wkssvc_NetrEnumerateComputerNames(struct pipes_struct *p,
struct wkssvc_NetrEnumerateComputerNames *r)
{
/* FIXME: Add implementation code here */
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;
}
|