public static bool Matches(this WindowsGroupPermission permission, WebName resource) { if (permission.IsServer || resource is null) { return(true); } var resourceString = resource.Value <string>(); if (Guid.TryParse(resourceString, out var resourceId)) { var matchingResourceID = permission.ResourceID == resourceId; if (matchingResourceID) { return(true); } } var resourcePath = resourceString?.Replace('/', '\\'); if (string.IsNullOrEmpty(resourcePath)) { return(true); } var p1 = resourcePath; if (p1.StartsWith(EnvironmentVariables.ResourcePath)) { p1 = p1.Replace(EnvironmentVariables.ResourcePath, ""); } var permissionResourcePath = permission.ResourcePath; if (permissionResourcePath is null) { return(false); } var p2 = "\\" + permissionResourcePath; var pathMatches = p1.StartsWith(p2); return(pathMatches); }