Disable reset admin password, added open selected computer cups
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
55
Program.cs
55
Program.cs
@@ -24,10 +24,16 @@ namespace domain_utility
|
||||
{ "Членство в глобальных группах", @"([*].+)", "Член групп:\t" }
|
||||
};
|
||||
|
||||
static readonly string[,] computerNameRegex = new string[,] {
|
||||
{ "^[a-zA-Z]+\\d+$", "R54-630300" }, // THE01
|
||||
{ "^\\d+[a-zA-Z]+\\d+$", "R54-" }, // 630300THE01
|
||||
{ "^[rR]\\d*[-]\\d+[a-zA-Z]+\\d+$", "-" } // R54-630300THE01
|
||||
};
|
||||
|
||||
private static string PingHost(string host)
|
||||
{
|
||||
string returnMessage = string.Empty;
|
||||
//PingOptions pingOptions = new PingOptions(128, true);
|
||||
//PingOptions pingOptions = new PingOptions(128, true); // TTL = 128
|
||||
PingOptions pingOptions = new PingOptions() { DontFragment = true };
|
||||
using (Ping ping = new Ping())
|
||||
{
|
||||
@@ -45,6 +51,9 @@ namespace domain_utility
|
||||
{
|
||||
case IPStatus.Success:
|
||||
{
|
||||
if (pingReply.RoundtripTime < 1)
|
||||
returnMessage = string.Format("Ответ от {0}: число байт={1} время<1ms TTL={2}", pingReply.Address, pingReply.Buffer.Length, pingReply.Options.Ttl);
|
||||
else
|
||||
returnMessage = string.Format("Ответ от {0}: число байт={1} время={2}ms TTL={3}", pingReply.Address, pingReply.Buffer.Length, pingReply.RoundtripTime, pingReply.Options.Ttl);
|
||||
//averageTime += pingReply.RoundtripTime;
|
||||
break;
|
||||
@@ -98,13 +107,12 @@ namespace domain_utility
|
||||
//Console.WriteLine("MinPasswordAge: " + directoryEntry.Properties["MinPasswordAge"].Value);
|
||||
//Console.WriteLine(TimeSpan.FromSeconds((int)directoryEntry.Properties["MinPasswordAge"].Value) - TimeSpan.FromSeconds((int)directoryEntry.Properties["PasswordAge"].Value));
|
||||
|
||||
//directoryEntry.Invoke("SetPassword", "Qwe12345");
|
||||
//directoryEntry.Properties["LockOutTime"].Value = 0;
|
||||
//directoryEntry.CommitChanges();
|
||||
directoryEntry.Invoke("SetPassword", "Qwe12345");
|
||||
directoryEntry.Properties["LockOutTime"].Value = 0;
|
||||
directoryEntry.CommitChanges();
|
||||
directoryEntry.Close();
|
||||
//Console.WriteLine("Пароль установлен.");
|
||||
string[] str = {};
|
||||
Main(str);
|
||||
Main();
|
||||
}
|
||||
|
||||
private static void ShowDomainUserInfo()
|
||||
@@ -261,13 +269,37 @@ namespace domain_utility
|
||||
StartPing();
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
private static void OpenComputerCups()
|
||||
{
|
||||
Console.Write("\nВведите имя компьютера: ");
|
||||
string input = Console.ReadLine().Trim();
|
||||
if (input == string.Empty || input.Length == 0)
|
||||
{
|
||||
OpenComputerCups();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < computerNameRegex.GetLength(0); i++)
|
||||
{
|
||||
if (Regex.Match(input, computerNameRegex[i, 0]).Success)
|
||||
{
|
||||
Process.Start($"http://{computerNameRegex[i, 1]}{input.ToUpper()}:631/printers");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Main();
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine("Выберите действие:\n" +
|
||||
"1 - посмотреть информацию о пользователе\n" +
|
||||
"2 - посмотреть дату последней загрузки компьютера\n" +
|
||||
"2 - посмотреть дату последней загрузки компьютера (только Windows)\n" +
|
||||
"3 - ping компьютера\n" +
|
||||
"4 - сброс пароля локального администратора");
|
||||
//"4 - сброс пароля локального администратора\n" +
|
||||
"4 - открыть CUPS введенного компьютера");
|
||||
string choice;
|
||||
while(true)
|
||||
{
|
||||
@@ -280,11 +312,12 @@ namespace domain_utility
|
||||
case 1: ShowDomainUserInfo(); break;
|
||||
case 2: ShowComputerBootupTime(); break;
|
||||
case 3: StartPing(); break;
|
||||
case 4: ResetAdminPassword(); break;
|
||||
//case 4: ResetAdminPassword(); break;
|
||||
case 4: OpenComputerCups(); break;
|
||||
default:
|
||||
{
|
||||
Console.WriteLine("Неправильный выбор!");
|
||||
Main(args);
|
||||
Main();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user