问题
I wrote this function to retrieve all Administrators Members SIDs:
private IList<byte[]> GetAdministratorsMembersSIDs()
{
IList<byte[]> adminMembers = new List<byte[]>();
SecurityIdentifier id = new SecurityIdentifier(administratorsSid);
string name = id.Translate(typeof(NTAccount)).Value.Split('\\')[1];
using (DirectoryEntry adminGroupEntry = new DirectoryEntry(string.Format("WinNT://./{0},group", name)))
{
foreach (object member in (IEnumerable)adminGroupEntry.Invoke("Members"))
{
using (DirectoryEntry memberEntry = new DirectoryEntry(member))
{
adminMembers.Add((byte[])memberEntry.InvokeGet("objectSid"));
}
}
}
return adminMembers;
}
In .NET Core 2.1 adminGroupEntry.Invoke("Members")
throw a System.PlatformNotSupportedException: IDispatch and IDispatchEx are not supported.
Anyone knows a workaround compatible in .NET Core 2.1 ?
[EDIT]
Issue fixed in .NET Core 3.0
来源:https://stackoverflow.com/questions/50601929/get-administratorsmembers-sids-in-net-core-2