Beispiel #1
0
    def test_LsarSetInformationPolicy(self):
        dce, rpctransport, policyHandle = self.connect()
        request = lsad.LsarQueryInformationPolicy()
        request['PolicyHandle'] = policyHandle
        request[
            'InformationClass'] = lsad.POLICY_INFORMATION_CLASS.PolicyAuditEventsInformation
        resp = dce.request(request)
        resp.dump()
        oldValue = resp['PolicyInformation']['PolicyAuditEventsInfo'][
            'AuditingMode']

        req = lsad.LsarSetInformationPolicy()
        req['PolicyHandle'] = policyHandle
        req['InformationClass'] = request['InformationClass']
        req['PolicyInformation'] = resp['PolicyInformation']
        req['PolicyInformation']['PolicyAuditEventsInfo']['AuditingMode'] = 0
        resp2 = dce.request(req)
        resp2.dump()

        resp = dce.request(request)
        resp.dump()

        req['PolicyInformation']['PolicyAuditEventsInfo'][
            'AuditingMode'] = oldValue
        resp2 = dce.request(req)
        resp2.dump()
    def test_LsarSetInformationPolicy(self):
        dce, rpctransport, policyHandle = self.connect()
        request = lsad.LsarQueryInformationPolicy()
        request['PolicyHandle'] = policyHandle
        request[
            'InformationClass'] = lsad.POLICY_INFORMATION_CLASS.PolicyAuditEventsInformation
        resp = dce.request(request)
        resp.dump()
        oldValue = resp['PolicyInformation']['PolicyAuditEventsInfo'][
            'AuditingMode']

        req = lsad.LsarSetInformationPolicy()
        req['PolicyHandle'] = policyHandle
        req['InformationClass'] = request['InformationClass']
        req['PolicyInformation'] = resp['PolicyInformation']
        req['PolicyInformation']['PolicyAuditEventsInfo']['AuditingMode'] = 0
        resp2 = dce.request(req)
        resp2.dump()

        resp = dce.request(request)
        resp.dump()

        req['PolicyInformation']['PolicyAuditEventsInfo'][
            'AuditingMode'] = oldValue
        resp2 = dce.request(req)
        resp2.dump()
        ################################################################################

        request[
            'InformationClass'] = lsad.POLICY_INFORMATION_CLASS.PolicyPrimaryDomainInformation
        resp = dce.request(request)
        resp.dump()
        oldValue = resp['PolicyInformation']['PolicyPrimaryDomainInfo']['Name']

        req = lsad.LsarSetInformationPolicy()
        req['PolicyHandle'] = policyHandle
        req['InformationClass'] = request['InformationClass']
        req['PolicyInformation'] = resp['PolicyInformation']
        req['PolicyInformation']['PolicyPrimaryDomainInfo']['Name'] = 'BETUS'
        resp2 = dce.request(req)
        resp2.dump()

        resp = dce.request(request)
        resp.dump()
        self.assertTrue('BETUS' == resp['PolicyInformation']
                        ['PolicyPrimaryDomainInfo']['Name'])

        req['PolicyInformation']['PolicyPrimaryDomainInfo']['Name'] = oldValue
        resp2 = dce.request(req)
        resp2.dump()

        ################################################################################

        request[
            'InformationClass'] = lsad.POLICY_INFORMATION_CLASS.PolicyAccountDomainInformation
        resp = dce.request(request)
        resp.dump()
        oldValue = resp['PolicyInformation']['PolicyAccountDomainInfo'][
            'DomainName']

        req = lsad.LsarSetInformationPolicy()
        req['PolicyHandle'] = policyHandle
        req['InformationClass'] = request['InformationClass']
        req['PolicyInformation'] = resp['PolicyInformation']
        req['PolicyInformation']['PolicyAccountDomainInfo'][
            'DomainName'] = 'BETUS'
        resp2 = dce.request(req)
        resp2.dump()

        resp = dce.request(request)
        resp.dump()

        self.assertTrue('BETUS' == resp['PolicyInformation']
                        ['PolicyAccountDomainInfo']['DomainName'])

        req['PolicyInformation']['PolicyAccountDomainInfo'][
            'DomainName'] = oldValue
        resp2 = dce.request(req)
        resp2.dump()