mirror of https://github.com/dahall/Vanara.git
BREAKING CHANGE: Removed methods that can cause unpredictable results due to ACE size differences.
parent
935fc50bf9
commit
37cceb6db5
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
|
using Vanara.Extensions;
|
||||||
using Vanara.InteropServices;
|
using Vanara.InteropServices;
|
||||||
using Vanara.PInvoke;
|
using Vanara.PInvoke;
|
||||||
using static Vanara.PInvoke.AdvApi32;
|
using static Vanara.PInvoke.AdvApi32;
|
||||||
|
@ -57,25 +58,9 @@ namespace Vanara.Security.AccessControl
|
||||||
/// <summary>Helper methods for working with Access Control structures.</summary>
|
/// <summary>Helper methods for working with Access Control structures.</summary>
|
||||||
public static class AccessControlHelper
|
public static class AccessControlHelper
|
||||||
{
|
{
|
||||||
public static ACCESS_ALLOWED_ACE GetAce(this PACL pAcl, int aceIndex)
|
public static uint GetAceCount(this PACL pAcl) => pAcl.GetAclInformation<ACL_SIZE_INFORMATION>().AceCount;
|
||||||
{
|
|
||||||
if (AdvApi32.GetAce(pAcl, aceIndex, out var acePtr))
|
|
||||||
return (ACCESS_ALLOWED_ACE)Marshal.PtrToStructure((IntPtr)acePtr, typeof(ACCESS_ALLOWED_ACE));
|
|
||||||
throw new System.ComponentModel.Win32Exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<ACCESS_ALLOWED_ACE> GetAces(this PACL pAcl)
|
public static uint GetAclSize(PACL pAcl) => pAcl.GetAclInformation<ACL_SIZE_INFORMATION>().AclBytesInUse;
|
||||||
{
|
|
||||||
var cnt = GetAceCount(pAcl);
|
|
||||||
for (var i = 0; i < cnt; i++)
|
|
||||||
yield return GetAce(pAcl, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static uint GetAceCount(this PACL pAcl) => GetAclInfo(pAcl).AceCount;
|
|
||||||
|
|
||||||
public static ACL_SIZE_INFORMATION GetAclInfo(PACL pAcl) => pAcl.GetAclInformation<ACL_SIZE_INFORMATION>();
|
|
||||||
|
|
||||||
public static uint GetAclSize(PACL pAcl) => GetAclInfo(pAcl).AclBytesInUse;
|
|
||||||
|
|
||||||
public static uint GetEffectiveRights(this PSID pSid, PSECURITY_DESCRIPTOR pSD)
|
public static uint GetEffectiveRights(this PSID pSid, PSECURITY_DESCRIPTOR pSD)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue