我的代碼可以工作,但我需要簡化的代碼,并且不適用于 Authenticated Users 組。還有其他計(jì)算有效權(quán)限的方法嗎?.NET 中是否有用于獲取特定用戶的有效文件夾權(quán)限的 api?我知道如何使用DirectorySecurity.GetAccessRules(). 但在這種情況下,我應(yīng)該手動(dòng)分析用戶的所有權(quán)限、組的權(quán)限,包括用戶、繼承的權(quán)限和文件夾的用戶權(quán)限。Windows API 中是否有可以通過平臺調(diào)用返回這些權(quán)限的函數(shù)?namespace DemoProject1{ class Program { static Dictionary<String, String> rightsmap = new Dictionary<String, String>(); [DllImport("advapi32.dll", SetLastError = true)] static extern uint GetEffectiveRightsFromAcl(IntPtr pDacl, ref TRUSTEE pTrustee, ref ACCESS_MASK pAccessRights); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)] struct TRUSTEE { IntPtr pMultipleTrustee; // must be null public int MultipleTrusteeOperation; public TRUSTEE_FORM TrusteeForm; public TRUSTEE_TYPE TrusteeType; [MarshalAs(UnmanagedType.LPStr)] public string ptstrName; } enum TRUSTEE_FORM { TRUSTEE_IS_SID, TRUSTEE_IS_NAME, TRUSTEE_BAD_FORM, TRUSTEE_IS_OBJECTS_AND_SID, TRUSTEE_IS_OBJECTS_AND_NAME } enum TRUSTEE_TYPE { TRUSTEE_IS_UNKNOWN, TRUSTEE_IS_USER, TRUSTEE_IS_GROUP, TRUSTEE_IS_DOMAIN, TRUSTEE_IS_ALIAS, TRUSTEE_IS_WELL_KNOWN_GROUP, TRUSTEE_IS_DELETED, TRUSTEE_IS_INVALID, TRUSTEE_IS_COMPUTER } [DllImport("advapi32.dll", CharSet = CharSet.Auto)] static extern uint GetNamedSecurityInfo( string pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, out IntPtr pSidOwner, out IntPtr pSidGroup, out IntPtr pDacl, out IntPtr pSacl, out IntPtr pSecurityDescriptor);
如何在 c# 或 C++ 中獲得文件或文件夾的有效權(quán)限???任何 API 的?
慕桂英3389331
2021-08-07 17:23:53