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
|
/*
Unix SMB/Netbios implementation.
Version 2.2
RPC pipe client
Copyright (C) Tim Potter 2000
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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
extern int DEBUGLEVEL;
extern pstring server;
static uint32 cmd_samr_connect(int argc, char **argv)
{
struct cli_state cli;
POLICY_HND pol, domain_pol, user_pol;
uint32 result = NT_STATUS_UNSUCCESSFUL;
struct ntuser_creds creds;
BOOL got_policy_hnd = False, got_domain_hnd = False;
DOM_SID sid;
if (argc > 1) {
printf("Usage: %s\n", argv[0]);
return 0;
}
/* Open a sam handle */
ZERO_STRUCT(cli);
init_rpcclient_creds(&creds);
if (cli_samr_initialise(&cli, server, &creds) == NULL) {
goto done;
}
if ((result = cli_samr_connect(&cli, server,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol)) != NT_STATUS_NOPROBLEMO) {
goto done;
}
got_policy_hnd = True;
string_to_sid(&sid, "S-1-5-21-1067277791-1719175008-3000797951");
if ((result = cli_samr_open_domain(&cli, &pol,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&sid, &domain_pol))
!= NT_STATUS_NOPROBLEMO) {
goto done;
}
got_domain_hnd = True;
if ((result = cli_samr_open_user(&cli, &domain_pol,
SEC_RIGHTS_MAXIMUM_ALLOWED, 500,
&user_pol))
!= NT_STATUS_NOPROBLEMO) {
goto done;
}
done:
if (got_domain_hnd) cli_samr_close(&cli, &domain_pol);
if (got_policy_hnd) cli_samr_close(&cli, &pol);
return result;
}
/* List of commands exported by this module */
struct cmd_set samr_commands[] = {
{ "samconnect", cmd_samr_connect, "Test" },
{ NULL, NULL, NULL }
};
|