修改子网 ad
介绍 (Introduction)
NoClientSites.exe is a NETLOGON.log parser that is used to get a list of all authentications that happened from clients where the Active Directory site is not defined.
NoClientSites.exe是NETLOGON.log解析器,用于获取未定义Active Directory站点的客户端发生的所有身份验证的列表。
These IP addresses can then, in turn, be used to add the appropriate sites and subnets into Active Directory Sites and Services.
然后,可以使用这些IP地址将适当的站点和子网添加到Active Directory站点和服务中。
下载 (Download)
A compiled version of NoClientSites.exe can be downloaded here, or compiled from the code provided at the end of this article.
可以从此处下载NoClientSites.exe的编译版本,也可以从本文结尾处提供的代码进行编译。
http://blog.ittelligence.com/wp-content/uploads/2018/07/NoClientSites.zip
http://blog.ittelligence.com/wp-content/uploads/2018/07/NoClientSites.zip
用法 (Usage)
NoClientSites.exe provides two methods to get IP addresses without client sites.
NoClientSites.exe提供了两种无需客户端站点即可获取IP地址的方法。
The first method allows parsing a whole folder that contains multiple NETLOGON.log files, pre-copied to a central location.
第一种方法允许解析包含多个NETLOGON.log文件的整个文件夹,这些文件已预先复制到一个中央位置。
NoClientSites.exe [PATHTONETLOGONFILES]
Alternatively, the NoClientSites.exe tool can be directly executed on each Domain Controllers
或者,可以在每个域控制器上直接执行NoClientSites.exe工具
NoClientSites.exe
代码 (The Code)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NoClientSites
{
class Program
{
static void Main(string[] args)
{
List<string> netlogonFilePaths = new List<string>();
if (args.Length == 1)
{
string logPath = args[0];
if (Directory.Exists(logPath))
{
foreach (string file in Directory.GetFiles(logPath, "*.log"))
{
netlogonFilePaths.Add(file);
}
}
}
else
{
netlogonFilePaths.Add(Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "Debug", "netlogon.log"));
}
if (netlogonFilePaths.Count > 0)
{
SortedSet<string> ipAddressesWithoutSites = new SortedSet<string>();
foreach (string netlogonFilePath in netlogonFilePaths)
{
processNetlogon(netlogonFilePath, ref ipAddressesWithoutSites);
}
//Display IP addresses from SortedSet
foreach (var ipAddress in ipAddressesWithoutSites)
{
Console.WriteLine(ipAddress);
}
}
else
{
ShowUsage();
}
}
static void processNetlogon(string netlogonFilePath, ref SortedSet<string> ipAddressesWithoutSites)
{
//Read Netlogon.log file line by line and add IP addresses into HashSet
try
{
StreamReader netlogonFile = new StreamReader(netlogonFilePath);
string line;
while ((line = netlogonFile.ReadLine()) != null)
{
if (line.Contains("NO_CLIENT_SITE"))
{
ipAddressesWithoutSites.Add(line.Replace("NO_CLIENT_SITE: ", "|").Split('|')[1].Trim().Split(' ')[1]);
}
}
}
catch
{
ShowUsage();
Console.WriteLine($"Error reading file \"{netlogonFilePath}\"");
}
}
private static void ShowUsage()
{
Console.WriteLine("");
Console.WriteLine(" _____ _____ _ _ _ _____ _ _ ");
Console.WriteLine("| | |___| | |_|___ ___| |_| __|_| |_ ___ ___ ");
Console.WriteLine("| | | | . | --| | | -_| | _|__ | | _| -_|_ -|");
Console.WriteLine("|_|___|___|_____|_|_|___|_|_|_| |_____|_|_| |___|___|");
Console.WriteLine("");
Console.WriteLine("NoClientSites.exe [PATHTONETLOGONFILES]");
Console.WriteLine("Or without a path directy on a Domain Controller");
Console.WriteLine("NoClientSites.exe");
Console.WriteLine("");
}
}
}
示范执行 (Demo Execution)
I hope you found this tutorial useful. You are encouraged to ask questions, report any bugs or make any other comments about it below.
希望本教程对您有所帮助。 鼓励您在下面提出问题,报告任何错误或对此作出任何其他评论。
Note: If you need further "Support" about this topic, please consider using the Ask a Question feature of Experts Exchange. I monitor questions asked and would be pleased to provide any additional support required in questions asked in this manner, along with other EE experts...
注意 :如果您需要有关此主题的更多“支持”,请考虑使用Experts Exchange 的“提问”功能。 我会监督提出的问题,并很高兴与其他电子工程师一起提供以这种方式提出的问题所需的任何其他支持...
Please do not forget to press the "Thumb's Up" button if you think this article was helpful and valuable for EE members.
如果您认为本文对EE成员有用且有价值,请不要忘记按“ Thumb's Up”按钮。
It also provides me with positive feedback. Thank you!
它还为我提供了积极的反馈。 谢谢!
翻译自: https://www.experts-exchange.com/articles/31846/Fixing-AD-Subnets.html
修改子网 ad