protected override void ProcessRecord() { using (var policy = new LsaPolicy(this.ComputerName, LsaPolicyAccessMask.ViewLocalInformation)) { var policyInfo = new LsaPolicyInformation() { DnsDomain = policy.QueryDnsDomainInformation(), Domain = policy.QueryAccountDomainInformation(), LocalDomain = policy.QueryLocalAccountDomainInformation(), MachineAccountSid = policy.QueryMachineAccountInformation() }; this.WriteObject(policyInfo); } }
public void LsaPolicy_QueryLocalAccountDomainInformation() { try { using (var policy = new LsaPolicy(LsaPolicyAccessMask.ViewLocalInformation)) { var result = policy.QueryLocalAccountDomainInformation(); } } catch (UnauthorizedAccessException e) { // This is expected. throw new AssertInconclusiveException("LSA-related tests require admin rights.", e); } }