public void GetGroupSidForCreatedFile() { using (var cleaner = new TestFileCleaner()) { using (var handle = Storage.CreateFile(cleaner.GetTestPath(), CreationDisposition.CreateNew)) { handle.IsInvalid.Should().BeFalse(); SID sid = Storage.GetPrimaryGroup(handle); sid.IdentifierAuthority.Should().Be(IdentifierAuthority.NT); string sidString = sid.ConvertSidToString(); AccountSidInformation info = sid.LookupAccountSid(); info.Usage.Should().Be(SidNameUse.User); info.Name.Should().Be(WInterop.SystemInformation.SystemInformation.GetUserName()); } } }
// [Fact] private void DumpAllWellKnownSids() { foreach (WellKnownSID type in Enum.GetValues(typeof(WellKnownSID))) { Debug.WriteLine(@"/// <summary>"); try { SID sid = Security.CreateWellKnownSid(type); AccountSidInformation info = sid.LookupAccountSid(); Debug.WriteLine($"/// {info.Name} ({sid.ConvertSidToString()}) [{info.Usage}]"); } catch { Debug.WriteLine($"/// Unable to retrieve"); } Debug.WriteLine(@"/// </summary>"); Debug.WriteLine($"{type} = {(int)type},"); Debug.WriteLine(""); } }
public void CreateWellKnownSid_Everyone() { SID sid = Security.CreateWellKnownSid(WellKnownSID.World); sid.IsValidSid().Should().BeTrue(); sid.Revision.Should().Be(1); sid.IdentifierAuthority.Should().Be(IdentifierAuthority.World); sid.GetSidSubAuthorityCount().Should().Be(1); sid.GetSidSubAuthority(0).Should().Be(0); sid.IsWellKnownSid(WellKnownSID.World).Should().BeTrue(); sid.ConvertSidToString().Should().Be("S-1-1-0"); AccountSidInformation info = sid.LookupAccountSid(); info.Name.Should().Be("Everyone"); info.DomainName.Should().Be(""); info.Usage.Should().Be(SidNameUse.WellKnownGroup); }