- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.cpp
More file actions
Latest commit
143 lines (139 loc) · 8.21 KB
/
Copy pathMainMenu.cpp
File metadata and controls
143 lines (139 loc) · 8.21 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
#ifndef UNICODE
#defineUNICODE
#endif
#include"stdafx.h"
#include"DLLFunctions.h"
#include"UserControl.h"
usingnamespacestd;
//вывод всех возможных команд
voidprintAllCommands(void)
{
cout << "...\n"
"# enter command:\n"
"# 1 - add user\n"
"# 2 - remove user\n"
"# 3 - add group\n"
"# 4 - remove group\n"
"# 5 - enumerate users\n"
"# 6 - add privilege to user or group\n"
"# 7 - remove user or group privilege\n"
"# 8 - remove all user or group privileges\n"
"# 9 - join group\n"
"# 10 - leave group\n"
"# 11 - print all user or group privileges\n"
"# 12 - print all groups\n"
"# 0 - exit\n";
return;
}
//главное меню в цикле
intmain(void)
{
setlocale(LC_ALL, "Russian");
Load_Dll();
int command;
TCHAR user_name[1024] = { 0 };
TCHAR group_name[1024] = { 0 };
TCHAR user_password[1024] = { 0 };
DWORD privilege_index = 0;
cout << "# userControl by dzagalskij" << endl;
//главное меню
while (1)
{
//распечатать все команды
printAllCommands();
cout << "# ";
//ввод команды пользователя
cin >> command;
//распознавание команды пользователя
//и выполнение определенной процедуры или функции
if (command == 1)
{
cout << "# enter user name:\n# ";
wcin >> user_name;
cout << "# enter user password:\n# ";
wcin >> user_password;
Add_User((LPWSTR)user_name, (LPWSTR)user_password);
}
elseif (command == 2)
{
wcout << "# enter user name:\n# ";
wcin >> user_name;
Delete_User((LPWSTR)user_name);
}
elseif (command == 3)
{
wcout << "# enter group name:\n# ";
wcin >> group_name;
Add_Group((LPWSTR)group_name);
}
elseif (command == 4)
{
wcout << "# enter group name:\n# ";
wcin >> group_name;
Delete_Group((LPWSTR)group_name);
}
elseif (command == 5)
{
Enumerate_Users(NULL);
}
elseif (command == 6)
{
wcout << "# enter user or group name:\n# ";
wcin >> user_name;
List_Privileges();
wcout << "# enter privilege index\n# ";
wcin >> privilege_index;
Set_User_Privileges((LPWSTR)user_name, privilege_index);
}
elseif (command == 7)
{
wcout << "# enter user or group name\n# ";
wcin >> user_name;
List_Privileges();
wcout << "# enter privilege index\n# ";
wcin >> privilege_index;
Clear_User_Privileges((LPWSTR)user_name, privilege_index);
}
elseif (command == 8)
{
wcout << "# enter user or group name\n# ";
wcin >> user_name;
Clear_All_User_Privileges((LPWSTR)user_name);
}
elseif (command == 9)
{
wcout << "# enter user name\n# ";
wcin >> user_name;
wcout << "# enter group name\n# ";
wcin >> group_name;
Assign_User_To_Group((LPWSTR)user_name, (LPWSTR)group_name);
}
elseif (command == 10)
{
wcout << "# enter user name\n# ";
wcin >> user_name;
wcout << "# enter group name\n# ";
wcin >> group_name;
Exclude_User_From_Group((LPWSTR)user_name, (LPWSTR)group_name);
}
elseif (command == 11)
{
wcout << "# enter user or group name\n# ";
wcin >> user_name;
printPrivileges(user_name);
}
elseif (command == 12)
{
Get_Groups_Enum();
}
elseif (command == 0)
{
Unload_Dll();
exit(0);
}
else
{
cout << "# incorrect command!\n";
}
}
}