首页 > 解决方案 > 使用 C# 从 Microsoft.GroupPolicy.GPTrustee 获取名称/Sid

问题描述

我正在尝试使用C# 中的 Get-GPPermission cmdlet 获取应用于组策略对象的权限。(不使用 Microsoft.GroupPolicy 命名空间)我能够获取权限类型和继承属性的值,但无法获取受托人的名称或 Sid .

下面是代码片段:

    Type gpTrusteeType = obj.Members["Trustee"].Value.GetType();
    object gpTrustee = Activator.CreateInstance(gpTrusteeType);   
    gpTrustee = obj.Members["Trustee"].Value;
    PropertyInfo name = gpTrusteeType.GetProperty("Name");
    String trusteeName = name.GetValue(gpTrustee, null).ToSring();

错误消息:没有为此对象定义无参数构造函数。

尝试使用 ConstructorInfo,但没有帮助

标签: c#powershellgroup-policy

解决方案


推荐阅读