Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentException for initializing SecurityIdentifier for WellKnownSidType.LogonIdsSid or WellKnownSidType.WinLocalLogonSid in .Net6 #1419

Open
iyrwis opened this issue Nov 27, 2023 · 0 comments

Comments

@iyrwis
Copy link

iyrwis commented Nov 27, 2023

Here is my reproduce code on .Net6, any suggestions?

using System;
using System.Security.Principal;

namespace ConsoleApp45
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("New param");

        var param = new SecurityIdentifier("S-1-5-21-198055498-3910363945-93989812");
        SecurityIdentifier sid;

        Console.WriteLine("New sid");

        foreach (WellKnownSidType type in Enum.GetValues(typeof(WellKnownSidType)))
        {
            if (type == WellKnownSidType.LogonIdsSid || type == WellKnownSidType.WinLocalLogonSid)
            {
                // these types can't be created, skip
                continue;
            }

            try
            {
                sid = new SecurityIdentifier(type, param);
                Console.WriteLine(type.ToString());
            }
            catch (ArgumentException)
            {
                Console.WriteLine($"The error type is: {type}");
            }
        }
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant