示例#1
0
    async def DRSGetNCChanges(self, guid, req_attributes={}):
        try:
            if self.handle is None:
                await rr(self.open())

            logger.debug('Calling DRSGetNCChanges for %s ' % guid)
            request = drsuapi.DRSGetNCChanges()
            request['hDrs'] = self.handle
            request['dwInVersion'] = 8

            request['pmsgIn']['tag'] = 8
            request['pmsgIn']['V8'][
                'uuidDsaObjDest'] = self.__NtdsDsaObjectGuid
            request['pmsgIn']['V8'][
                'uuidInvocIdSrc'] = self.__NtdsDsaObjectGuid

            dsName = drsuapi.DSNAME()
            dsName['SidLen'] = 0
            dsName['Guid'] = string_to_bin(guid)  #guid.to_bytes()
            dsName['Sid'] = ''
            dsName['NameLen'] = 0
            dsName['StringName'] = ('\x00')

            dsName['structLen'] = len(dsName.getData())

            request['pmsgIn']['V8']['pNC'] = dsName

            request['pmsgIn']['V8']['usnvecFrom']['usnHighObjUpdate'] = 0
            request['pmsgIn']['V8']['usnvecFrom']['usnHighPropUpdate'] = 0

            request['pmsgIn']['V8']['pUpToDateVecDest'] = NULL

            request['pmsgIn']['V8'][
                'ulFlags'] = drsuapi.DRS_INIT_SYNC | drsuapi.DRS_WRIT_REP
            request['pmsgIn']['V8']['cMaxObjects'] = 1
            request['pmsgIn']['V8']['cMaxBytes'] = 0
            request['pmsgIn']['V8']['ulExtendedOp'] = drsuapi.EXOP_REPL_OBJ
            if self.__ppartialAttrSet is None:
                self.__prefixTable = []
                self.__ppartialAttrSet = drsuapi.PARTIAL_ATTR_VECTOR_V1_EXT()
                self.__ppartialAttrSet['dwVersion'] = 1
                self.__ppartialAttrSet['cAttrs'] = len(req_attributes)
                for attId in list(req_attributes.values()):
                    self.__ppartialAttrSet['rgPartialAttr'].append(
                        drsuapi.MakeAttid(self.__prefixTable, attId))
            request['pmsgIn']['V8']['pPartialAttrSet'] = self.__ppartialAttrSet
            request['pmsgIn']['V8']['PrefixTableDest']['PrefixCount'] = len(
                self.__prefixTable)
            request['pmsgIn']['V8']['PrefixTableDest'][
                'pPrefixEntry'] = self.__prefixTable
            request['pmsgIn']['V8']['pPartialAttrSetEx1'] = NULL

            data, err = await self.dce.request(request)
            return data, err
        except Exception as e:
            print('err!')
            return None, e
示例#2
0
    async def DRSGetNCChanges(self, userEntry):
        if self.handle is None:
            self.open()

        logger.debug('Calling DRSGetNCChanges for %s ' % userEntry)
        request = drsuapi.DRSGetNCChanges()
        request['hDrs'] = self.__hDrs
        request['dwInVersion'] = 8

        request['pmsgIn']['tag'] = 8
        request['pmsgIn']['V8']['uuidDsaObjDest'] = self.__NtdsDsaObjectGuid
        request['pmsgIn']['V8']['uuidInvocIdSrc'] = self.__NtdsDsaObjectGuid

        dsName = drsuapi.DSNAME()
        dsName['SidLen'] = 0
        dsName['Guid'] = string_to_bin(userEntry[1:-1])
        dsName['Sid'] = ''
        dsName['NameLen'] = 0
        dsName['StringName'] = ('\x00')

        dsName['structLen'] = len(dsName.getData())

        request['pmsgIn']['V8']['pNC'] = dsName

        request['pmsgIn']['V8']['usnvecFrom']['usnHighObjUpdate'] = 0
        request['pmsgIn']['V8']['usnvecFrom']['usnHighPropUpdate'] = 0

        request['pmsgIn']['V8']['pUpToDateVecDest'] = NULL

        request['pmsgIn']['V8'][
            'ulFlags'] = drsuapi.DRS_INIT_SYNC | drsuapi.DRS_WRIT_REP
        request['pmsgIn']['V8']['cMaxObjects'] = 1
        request['pmsgIn']['V8']['cMaxBytes'] = 0
        request['pmsgIn']['V8']['ulExtendedOp'] = drsuapi.EXOP_REPL_OBJ
        if self.__ppartialAttrSet is None:
            self.__prefixTable = []
            self.__ppartialAttrSet = drsuapi.PARTIAL_ATTR_VECTOR_V1_EXT()
            self.__ppartialAttrSet['dwVersion'] = 1
            self.__ppartialAttrSet['cAttrs'] = len(NTDSHashes.ATTRTYP_TO_ATTID)
            for attId in list(NTDSHashes.ATTRTYP_TO_ATTID.values()):
                self.__ppartialAttrSet['rgPartialAttr'].append(
                    drsuapi.MakeAttid(self.__prefixTable, attId))
        request['pmsgIn']['V8']['pPartialAttrSet'] = self.__ppartialAttrSet
        request['pmsgIn']['V8']['PrefixTableDest']['PrefixCount'] = len(
            self.__prefixTable)
        request['pmsgIn']['V8']['PrefixTableDest'][
            'pPrefixEntry'] = self.__prefixTable
        request['pmsgIn']['V8']['pPartialAttrSetEx1'] = NULL

        return self.dce.request(request)