我想增强我正在编写的 C# 程序,以便在其中一个或多个离线时它可以利用全局目录 DC 列表中的任何一个。我想编写一个方法,根据 ADDS 是否在目标服务器上运行(而不仅仅是服务器是否可 ping 通)来返回 bool 值:
public bool DC_is_Alive(string DomainControllerFQDN)
{
...
}
Run Code Online (Sandbox Code Playgroud) 我有一个 WPF 用户控件,其中包含BindableRichTextBox:
xmlns:controls="clr-namespace:SysadminsLV.WPF.OfficeTheme.Controls;assembly=Wpf.OfficeTheme"
.
.
.
<controls:BindableRichTextBox Background="Black"
Foreground="White"
FontFamily="Consolas"
FontSize="12"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
VerticalScrollBarVisibility="Auto"
IsUndoEnabled="False"
Document="{Binding Contents}"/>
Run Code Online (Sandbox Code Playgroud)
内容由 ViewModel 属性控制Document:
using System.Windows.Documents;
class MyViewModel : ILogServerContract
{
readonly Paragraph _paragraph;
public MyViewModel()
{
_paragraph = new Paragraph();
Contents = new FlowDocument(_paragraph);
}
public FlowDocument Contents { get; }
//Log Server Contract Write method (accessed via NetPipe)
public void WriteLine(string text, int debugLevel)
{
//figure out formatting stuff based on debug level. not important
_paragraph.Inlines.Add(new Run(text) …Run Code Online (Sandbox Code Playgroud) 我需要在一组远程服务器上配置审计策略。我正在尝试使用 Invoke-Command commandlet 在每台服务器上运行 auditpol.exe。问题是我似乎无法从 auditpol 命令中捕获任何输出。
我尝试了显而易见的(将 Invoke-Command 的结果分配给一个字符串):
> $command = "Start-Process -FilePath `"auditpol.exe`" -ArgumentList `"/set`", `"/subcategory`", `"```"File System```"`", `"/success:enable`""
> $command
"auditpol.exe" -ArgumentList "/set", "/subcategory", "`"File System`"", "/success:enable"
> $out = Invoke-Command -ComputerName MyServer -ScriptBlock {$command}
> $out
>
Run Code Online (Sandbox Code Playgroud)
但是 $out 是空的。
我还使用 Wait-Job 和 Receive-Job尝试了此 MSDN 博客中详述的方法。结果有些令人鼓舞,但尚无定论:
> $command = "Start-Process -FilePath `"auditpol.exe`" -ArgumentList `"/set`", `"/subcategory`", `"```"File System```"`", `"/success:enable`""
> $command
"auditpol.exe" -ArgumentList "/set", "/subcategory", "`"File System`"", "/success:enable"
> $job = Invoke-Command -ComputerName MyServer …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Org.BouncyCastle.X509 转储证书吊销列表(CRL)的内容。在此用例中,我需要获取“十六进制”字符串表示形式的证书序列号列表,正如它们出现在证书 MMC 管理单元中一样(示例值为16a03c2c000000000594)。
\n\n我能够达到这样的程度:我有一个 X509CRLEntry 对象的集合可供迭代,但SerialNumber属性的类型为Org.BouncyCastle.Math.BigInteger。这种类型有一个ToString()的实现,但是,返回的值对我来说不可用:
\n\npublic CRLProc(string CRLFile)\n {\n X509CrlParser Parser = new X509CrlParser();\n X509Crl CRL = Parser.ReadCrl(File.ReadAllBytes(CRLFile));\n NextUpdate = CRL.NextUpdate.Value;\n var RevokedCerts = CRL.GetRevokedCertificates();\n\n foreach(X509CrlEntry entry in RevokedCerts)\n {\n //Target value (first SN in CRL): 16a03c2c000000000594\n\n string serialNumber = entry.SerialNumber.ToString();\n //serialNumber = "106847877515466973906324" (Nope)\n\n string serialFromBytes = Encoding.Default.GetString(entry.SerialNumber.ToByteArray());\n //serialFromBytes = "\\u0016\xc2\xa0<,\\0\\0\\0\\0\\u0005\xe2\x80\x9d" (That\'s a hard NO)\n\n string serialFromBigInt = entry.SerialNumber.LongValue.ToString("X");\n //serialFromBigInt = "3C2C000000000594" (OK, now we\'re getting …Run Code Online (Sandbox Code Playgroud) 情况:我编写了一个用户通过 RDP 访问的 WinForms 应用程序。应用程序的性质是两个用户不能同时运行该应用程序。我们遇到的问题是人们会忘记关闭应用程序,基本上将其他用户锁定在外面。
我想要做的是添加功能以在 x 分钟后自动关闭应用程序。我意识到我需要为此使用线程,因为在主线程中标记时间会冻结应用程序。我没有检测活动/不活动的关键需求,但如果这很简单,我肯定想知道。
在此先感谢您的帮助!