Ejemplo n.º 1
0
    def _samdb_fetch_pfm_and_schi(self):
        """Fetch prefixMap and schemaInfo stored in SamDB using LDB connection"""
        samdb = self.ldb_dc1
        res = samdb.search(base=samdb.get_schema_basedn(),
                           scope=SCOPE_BASE,
                           attrs=["prefixMap", "schemaInfo"])

        pfm = ndr_unpack(drsblobs.prefixMapBlob, str(res[0]['prefixMap']))

        schi = drsuapi.DsReplicaOIDMapping()
        schi.id_prefix = 0

        if 'schemaInfo' in res[0]:
            schi.oid.length = len(map(ord, str(res[0]['schemaInfo'])))
            schi.oid.binary_oid = map(ord, str(res[0]['schemaInfo']))
        else:
            schema_info = drsblobs.schemaInfoBlob()
            schema_info.revision = 0
            schema_info.marker = 0xFF
            schema_info.invocation_id = misc.GUID(samdb.get_invocation_id())
            schi.oid.length = len(map(ord, ndr_pack(schema_info)))
            schi.oid.binary_oid = map(ord, ndr_pack(schema_info))

        pfm.ctr.mappings = pfm.ctr.mappings + [schi]
        pfm.ctr.num_mappings += 1
        return pfm.ctr
Ejemplo n.º 2
0
    def _samdb_fetch_pfm_and_schi(self):
        """Fetch prefixMap and schemaInfo stored in SamDB using LDB connection"""
        samdb = self.ldb_dc1
        res = samdb.search(base=samdb.get_schema_basedn(),
                           scope=SCOPE_BASE,
                           attrs=["prefixMap", "schemaInfo"])

        pfm = ndr_unpack(drsblobs.prefixMapBlob, res[0]['prefixMap'][0])

        schi = drsuapi.DsReplicaOIDMapping()
        schi.id_prefix = 0
        if 'schemaInfo' in res[0]:
            binary_oid = [
                x if isinstance(x, int) else ord(x)
                for x in res[0]['schemaInfo'][0]
            ]
            schi.oid.length = len(binary_oid)
            schi.oid.binary_oid = binary_oid
        else:
            schema_info = drsblobs.schemaInfoBlob()
            schema_info.revision = 0
            schema_info.marker = 0xFF
            schema_info.invocation_id = misc.GUID(samdb.get_invocation_id())

            binary_oid = [
                x if isinstance(x, int) else ord(x)
                for x in ndr_pack(schema_info)
            ]
            # you have to set the length before setting binary_oid
            schi.oid.length = len(binary_oid)
            schi.oid.binary_oid = binary_oid

        pfm.ctr.mappings = pfm.ctr.mappings + [schi]
        pfm.ctr.num_mappings += 1
        return pfm.ctr
Ejemplo n.º 3
0
    def _samdb_fetch_pfm_and_schi(self):
        """Fetch prefixMap and schemaInfo stored in SamDB using LDB connection"""
        samdb = self.ldb_dc1
        res = samdb.search(base=samdb.get_schema_basedn(), scope=SCOPE_BASE,
                           attrs=["prefixMap", "schemaInfo"])

        pfm = ndr_unpack(drsblobs.prefixMapBlob,
                         str(res[0]['prefixMap']))

        schi = drsuapi.DsReplicaOIDMapping()
        schi.id_prefix = 0

        if 'schemaInfo' in res[0]:
            schi.oid.length = len(map(ord, str(res[0]['schemaInfo'])))
            schi.oid.binary_oid = map(ord, str(res[0]['schemaInfo']))
        else:
            schema_info = drsblobs.schemaInfoBlob()
            schema_info.revision = 0
            schema_info.marker = 0xFF
            schema_info.invocation_id = misc.GUID(samdb.get_invocation_id())
            schi.oid.length = len(map(ord, ndr_pack(schema_info)))
            schi.oid.binary_oid = map(ord, ndr_pack(schema_info))

        pfm.ctr.mappings = pfm.ctr.mappings + [schi]
        pfm.ctr.num_mappings += 1
        return pfm.ctr
Ejemplo n.º 4
0
def _samdb_fetch_schi(samdb):
    """Fetch schemaInfo stored in SamDB using LDB connection"""
    res = samdb.search(base=samdb.get_schema_basedn(), expression="", scope=SCOPE_BASE, attrs=["*"])
    assert len(res) == 1
    if 'schemaInfo' in res[0]:
        pfm_schi = ndr_unpack(drsblobs.schemaInfoBlob,
                              str(res[0]['schemaInfo']))
    else:
        pfm_schi = drsblobs.schemaInfoBlob()
        pfm_schi.marker = 0xFF;
    return pfm_schi
Ejemplo n.º 5
0
 def _getSchemaInfo(self):
     try:
         schema_info_data = self.sam_db.searchone(attribute="schemaInfo",
                                                  basedn=self.schema_dn,
                                                  expression="(objectClass=*)",
                                                  scope=SCOPE_BASE)
         self.assertEqual(len(schema_info_data), 21)
         schema_info = ndr_unpack(schemaInfoBlob, schema_info_data)
         self.assertEqual(schema_info.marker, 0xFF)
     except KeyError:
         # create default schemaInfo if
         # attribute value is not created yet
         schema_info = schemaInfoBlob()
         schema_info.revision = 0
         schema_info.invocation_id = self.invocation_id
     return schema_info
Ejemplo n.º 6
0
 def _getSchemaInfo(self):
     try:
         schema_info_data = self.sam_db.searchone(attribute="schemaInfo",
                                                  basedn=self.schema_dn,
                                                  expression="(objectClass=*)",
                                                  scope=SCOPE_BASE)
         self.assertEqual(len(schema_info_data), 21)
         schema_info = ndr_unpack(schemaInfoBlob, schema_info_data)
         self.assertEqual(schema_info.marker, 0xFF)
     except KeyError:
         # create default schemaInfo if
         # attribute value is not created yet
         schema_info = schemaInfoBlob()
         schema_info.revision = 0
         schema_info.invocation_id = self.invocation_id
     return schema_info