def on_login(self, context, connection):
        """
        On a successful LDAP login we perform a search for the targets' SID, their Security Decriptors and the principal's SID if there is one specified
        """

        context.log.highlight("Be carefull, this module cannot read the DACLS recursively.")
        self.baseDN = connection.ldapConnection._baseDN
        self.ldap_session = connection.ldapConnection

        # Searching for the principal SID
        if self.principal_sAMAccountName is not None:
            _lookedup_principal = self.principal_sAMAccountName
            try:
                self.principal_sid = format_sid(
                    self.ldap_session.search(
                        searchBase=self.baseDN,
                        searchFilter="(sAMAccountName=%s)" % escape_filter_chars(_lookedup_principal),
                        attributes=["objectSid"],
                    )[0][
                        1
                    ][0][
                        1
                    ][0]
                )
                context.log.highlight("Found principal SID to filter on: %s" % self.principal_sid)
            except Exception as e:
                context.log.fail("Principal SID not found in LDAP (%s)" % _lookedup_principal)
                exit(1)

        # Searching for the targets SID and their Security Decriptors
        # If there is only one target
        if (self.target_sAMAccountName or self.target_DN) and self.target_file is None:
            # Searching for target account with its security descriptor
            try:
                self.search_target_principal_security_descriptor(context, connection)
                # Extract security descriptor data
                self.target_principal_dn = self.target_principal[0]
                self.principal_raw_security_descriptor = str(self.target_principal[1][0][1][0]).encode("latin-1")
                self.principal_security_descriptor = ldaptypes.SR_SECURITY_DESCRIPTOR(data=self.principal_raw_security_descriptor)
                context.log.highlight("Target principal found in LDAP (%s)" % self.target_principal[0])
            except Exception as e:
                context.log.fail("Target SID not found in LDAP (%s)" % self.target_sAMAccountName)
                exit(1)

            if self.action == "read":
                self.read(context)
            if self.action == "backup":
                self.backup(context)

        # If there are multiple targets
        else:
            targets = self.target_file.readlines()
            for target in targets:
                try:
                    self.target_sAMAccountName = target.strip()
                    # Searching for target account with its security descriptor
                    self.search_target_principal_security_descriptor(context, connection)
                    # Extract security descriptor data
                    self.target_principal_dn = self.target_principal[0]
                    self.principal_raw_security_descriptor = str(self.target_principal[1][0][1][0]).encode("latin-1")
                    self.principal_security_descriptor = ldaptypes.SR_SECURITY_DESCRIPTOR(data=self.principal_raw_security_descriptor)
                    context.log.highlight("Target principal found in LDAP (%s)" % self.target_sAMAccountName)
                except Exception as e:
                    context.log.fail("Target SID not found in LDAP (%s)" % self.target_sAMAccountName)
                    continue

                if self.action == "read":
                    self.read(context)
                if self.action == "backup":
                    self.backup(context)

        On a successful LDAP login we perform a search for the targets' SID, their Security Decriptors and the principal's SID if there is one specified
        
cme/modules/daclread.py