Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 public void LsaPolicy_QueryDnsDomainInformation()
 {
     try
     {
         using (var policy = new LsaPolicy(LsaPolicyAccessMask.ViewLocalInformation))
         {
             var result = policy.QueryDnsDomainInformation();
         }
     }
     catch (UnauthorizedAccessException e)
     {
         // This is expected.
         throw new AssertInconclusiveException("LSA-related tests require admin rights.", e);
     }
 }
Esempio n. 3
0
        public void LsaPolicy_SetDnsDomainInformation()
        {
            try
            {
                using (var policy = new LsaPolicy(LsaPolicyAccessMask.ViewLocalInformation | LsaPolicyAccessMask.TrustAdmin))
                {
                    // Retrieve domain info
                    var info = policy.QueryDnsDomainInformation();

                    // Now try to set it to the same value.
                    // BE CAREFUL WHEN TESTING THIS!!!
                    policy.SetDnsDomainInformation(info);
                }
            }
            catch (UnauthorizedAccessException e)
            {
                // This is expected.
                throw new AssertInconclusiveException("LSA-related tests require admin rights.", e);
            }
        }