MCPcopy Index your code
hub / github.com/secdev/scapy / LDAP_Exception

Class LDAP_Exception

scapy/layers/ldap.py:1713–1740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1711
1712
1713class LDAP_Exception(RuntimeError):
1714 __slots__ = ["resultCode", "diagnosticMessage"]
1715
1716 def __init__(self, *args, **kwargs):
1717 resp = kwargs.pop("resp", None)
1718 if resp:
1719 self.resultCode = resp.protocolOp.resultCode
1720 self.diagnosticMessage = resp.protocolOp.diagnosticMessage.val.rstrip(
1721 b"\x00"
1722 ).decode(errors="backslashreplace")
1723 else:
1724 self.resultCode = kwargs.pop("resultCode", None)
1725 self.diagnosticMessage = kwargs.pop("diagnosticMessage", None)
1726 super(LDAP_Exception, self).__init__(*args, **kwargs)
1727 # If there's a 'data' string argument, attempt to parse the error code.
1728 try:
1729 m = re.match(r"(\d+): LdapErr.*", self.diagnosticMessage)
1730 if m:
1731 errstr = m.group(1)
1732 err = int(errstr, 16)
1733 if err in STATUS_ERREF:
1734 self.diagnosticMessage = self.diagnosticMessage.replace(
1735 errstr, errstr + " (%s)" % STATUS_ERREF[err], 1
1736 )
1737 except ValueError:
1738 pass
1739 # Add note if this exception is raised
1740 self.add_note(self.diagnosticMessage)
1741
1742
1743class LDAP_Client(object):

Callers 5

bindMethod · 0.85
searchMethod · 0.85
modifyMethod · 0.85
addMethod · 0.85
modifydnMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected