forked from nick627/UserControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserControl.cpp
More file actions
150 lines (131 loc) · 8.19 KB
/
UserControl.cpp
File metadata and controls
150 lines (131 loc) · 8.19 KB
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
#ifndef UNICODE
#define UNICODE
#endif
#include "stdafx.h"
#include "LoadDll.h"
#include "GetUserInfo.h"
#include "SetUserInfo.h"
#include "CLI.hpp"
using namespace std;
// au, ru, ag, rg, eu, ap, cp, jg, lg
LPWSTR help_str = (LPWSTR)L"Usage:\n"
"\t /au - Add user\n"
"\t /ru - Remove user\n"
"\t /ag - Add group\n"
"\t /rg - Remove group\n"
"\t /eu - Enumerate users\n"
"\t /ap - Add privilege to user\n"
"\t /rp - Remove user privilege\n"
"\t /rap - Remove all user privileges\n"
"\t /jg - Join group\n"
"\t /lg - Leave group\n"
"\n";
int wmain(int argc, wchar_t *argv[])
{
setlocale(LC_ALL, "Russian");
Load_Dll();
TCHAR user_name[1024] = { 0 };
TCHAR group_name[1024] = { 0 };
TCHAR user_password[1024] = { 0 };
DWORD privilege_index = 0;
if (argc == 1)
{
wprintf(help_str);
return 0;
}
else if (argc == 2)
{
if(wcscmp(argv[1], L"/au") == 0)
{
wcout << "enter username\n";
wcin >> user_name;
wcout << "enter password\n";
wcin >> user_password;
Add_User((LPWSTR)user_name, (LPWSTR)user_password);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/ru") == 0)
{
wcout << "enter username\n";
wcin >> user_name;
Delete_User((LPWSTR)user_name);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/ag") == 0)
{
wcout << "enter group name\n";
wcin >> group_name;
Add_Group((LPWSTR)group_name);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/rg") == 0)
{
wcout << "enter group name\n";
wcin >> group_name;
Delete_Group((LPWSTR)group_name);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/eu") == 0)
{
Enumerate_Users(NULL);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/ap") == 0)
{
wcout << "enter username\n";
wcin >> user_name;
list_Privileges();
wcout << "enter privilege index\n";
wcin >> privilege_index;
Set_User_Privileges((LPWSTR)user_name, privilege_index);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/rp") == 0)
{
wcout << "enter username\n";
wcin >> user_name;
list_Privileges();
wcout << "enter privilege index\n";
wcin >> privilege_index;
Clear_User_Privileges((LPWSTR)user_name, privilege_index);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/rap") == 0)
{
wcout << "enter username\n";
wcin >> user_name;
Clear_All_User_Privileges((LPWSTR)user_name);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/jg") == 0)
{
wcout << "enter username\n";
wcin >> user_name;
wcout << "enter group name\n";
wcin >> group_name;
Assign_User_To_Group((LPWSTR)user_name, (LPWSTR)group_name);
Unload_Dll();
return 0;
}
if (wcscmp(argv[1], L"/lg") == 0)
{
wcout << "enter username\n";
wcin >> user_name;
wcout << "enter group name\n";
wcin >> group_name;
Exclude_User_From_Group((LPWSTR)user_name, (LPWSTR)group_name);
Unload_Dll();
return 0;
}
}
Unload_Dll();
return 0;
}