def load_connection(self, samdb):
        """Given a NTDSConnection object with an prior initialization
        for the object's DN, search for the DN and load attributes
        from the samdb.
        """
        attrs = [ "options",
                  "enabledConnection",
                  "schedule",
                  "whenCreated",
                  "objectGUID",
                  "transportType",
                  "fromServer",
                  "systemFlags" ]
        try:
            res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
                               attrs=attrs)

        except ldb.LdbError, (enum, estr):
            raise Exception("Unable to find nTDSConnection for (%s) - (%s)" %
                            (self.dnstr, estr))

        msg = res[0]

        if "options" in msg:
            self.options = int(msg["options"][0])

        if "enabledConnection" in msg:
            if msg["enabledConnection"][0].upper().lstrip().rstrip() == "TRUE":
                self.enabled = True

        if "systemFlags" in msg:
            self.system_flags = int(msg["systemFlags"][0])

        if "objectGUID" in msg:
            self.guid = \
                misc.GUID(samdb.schema_format_value("objectGUID",
                                                    msg["objectGUID"][0]))

        if "transportType" in msg:
            dsdn = dsdb_Dn(samdb, msg["tranportType"][0])
            self.load_connection_transport(str(dsdn.dn))

        if "schedule" in msg:
            self.schedule = ndr_unpack(drsblobs.replSchedule, msg["schedule"][0])

        if "whenCreated" in msg:
            self.whenCreated = ldb.string_to_time(msg["whenCreated"][0])

        if "fromServer" in msg:
            dsdn = dsdb_Dn(samdb, msg["fromServer"][0])
            self.from_dnstr = str(dsdn.dn)
            assert self.from_dnstr is not None
dataset/ETHPy150Open byt3bl33d3r/pth-toolkit/lib/python2.7/site-packages/samba/kcc_utils.py/NTDSConnection.load_connection/original