예제 #1
0
 private static FirewallFilterCondition ConvertUserId(FirewallFilterCondition condition)
 {
     if (condition.FieldKey != FirewallConditionGuids.FWPM_CONDITION_ALE_USER_ID)
     {
         return(condition);
     }
     if (condition.Value.Type == FirewallDataType.Sid)
     {
         return(condition);
     }
     if (!(condition.Value.Value is FirewallTokenInformation token_info))
     {
         throw new ArgumentException("Must specify a SID or FirewallTokenInformation for FWPM_CONDITION_ALE_USER_ID.");
     }
     if (token_info.UserSid == null)
     {
         throw new ArgumentException("Must specify a user SID for the TokenInformation for FWPM_CONDITION_ALE_USER_ID.");
     }
     return(new FirewallFilterCondition(condition.MatchType, condition.FieldKey, FirewallValue.FromSid(token_info.UserSid)));
 }
 /// <summary>
 /// Add a package SID condition.
 /// </summary>
 /// <param name="match_type">The match type.</param>
 /// <param name="package_sid">The package SID.</param>
 public void AddPackageSid(FirewallMatchType match_type, Sid package_sid)
 {
     AddCondition(match_type, FirewallConditionGuids.FWPM_CONDITION_ALE_PACKAGE_ID, FirewallValue.FromSid(package_sid));
 }