/// <summary> /// Map all generic access in this security descriptor to a specific type. /// </summary> /// <param name="generic_mapping">The generic mapping.</param> public void MapGenericAccess(GenericMapping generic_mapping) { if (Dacl != null) { foreach (Ace ace in Dacl) { ace.Mask = generic_mapping.MapMask(ace.Mask); } } if (ProcessTrustLabel != null) { ProcessTrustLabel.Mask = generic_mapping.MapMask(ProcessTrustLabel.Mask); } }
/// <summary> /// Convert an enumerable access rights to a string /// </summary> /// <param name="granted_access">The granted access mask.</param> /// <param name="generic_mapping">Generic mapping for object type.</param> /// <param name="enum_type">Enum type to convert to string.</param> /// <param name="map_to_generic">True to try and convert to generic rights where possible.</param> /// <returns>The string format of the access rights</returns> public static string GrantedAccessAsString(AccessMask granted_access, GenericMapping generic_mapping, Type enum_type, bool map_to_generic) { if (granted_access == 0) { return("None"); } AccessMask mapped_access = generic_mapping.MapMask(granted_access); if (map_to_generic) { mapped_access = generic_mapping.UnmapMask(mapped_access); } else if (generic_mapping.HasAll(granted_access)) { return("Full Access"); } return(AccessRightsToString(enum_type, mapped_access)); }
/// <summary> /// Checks if an access mask is valid for access of this object type. /// </summary> /// <param name="access_mask">The access mask to check</param> /// <returns>True if it valid access</returns> public bool IsValidAccess(AccessMask access_mask) { return((GenericMapping.MapMask(access_mask) & ~ValidAccess).IsEmpty); }
/// <summary> /// Map generic access rights to specific access rights for this type /// </summary> /// <param name="access_mask">The access mask to map</param> /// <returns>The mapped access mask</returns> public AccessMask MapGenericRights(AccessMask access_mask) { return(GenericMapping.MapMask(access_mask)); }
/// <summary> /// Map generic access rights to specific access rights for this type /// </summary> /// <param name="access_mask">The access mask to map</param> /// <returns>The mapped access mask</returns> public uint MapGenericRights(uint access_mask) { return(GenericMapping.MapMask(access_mask)); }
/// <summary> /// Checks if a access mask represents a full permission on this type /// </summary> /// <param name="access_mask">The access mask to check</param> /// <returns>True if it has full permissions</returns> public bool HasFullPermission(uint access_mask) { access_mask = GenericMapping.MapMask(access_mask); return((access_mask & GenericMapping.GenericAll) == GenericMapping.GenericAll); }
/// <summary> /// Checks if a access mask represents a execute permission on this type /// </summary> /// <param name="access_mask">The access mask to check</param> /// <returns>True if it has execute permissions</returns> public bool HasExecutePermission(uint access_mask) { access_mask = GenericMapping.MapMask(access_mask); return((access_mask & GenericMapping.GenericExecute & ~GenericMapping.GenericRead) != 0); }