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

Method bind

scapy/layers/ldap.py:1948–2206  ·  view source on GitHub ↗

Send Bind request. :param mech: one of LDAP_BIND_MECHS :param ssp: the SSP object to use for binding :param sign: request signing when binding :param encrypt: request encryption when binding : This acts differently based on the :mech: provi

(
        self,
        mech,
        ssp=None,
        sign=False,
        encrypt=False,
        simple_username=None,
        simple_password=None,
    )

Source from the content-addressed store, hash-verified

1946 return resp
1947
1948 def bind(
1949 self,
1950 mech,
1951 ssp=None,
1952 sign=False,
1953 encrypt=False,
1954 simple_username=None,
1955 simple_password=None,
1956 ):
1957 """
1958 Send Bind request.
1959
1960 :param mech: one of LDAP_BIND_MECHS
1961 :param ssp: the SSP object to use for binding
1962
1963 :param sign: request signing when binding
1964 :param encrypt: request encryption when binding
1965
1966 :
1967 This acts differently based on the :mech: provided during initialization.
1968 """
1969 # Store and check consistency
1970 self.mech = mech
1971 self.ssp = ssp # type: SSP
1972 self.sign = sign
1973 self.encrypt = encrypt
1974 self.sspcontext = None
1975
1976 if mech is None or not isinstance(mech, LDAP_BIND_MECHS):
1977 raise ValueError(
1978 "'mech' attribute is required and must be one of LDAP_BIND_MECHS."
1979 )
1980
1981 if mech == LDAP_BIND_MECHS.SASL_GSSAPI:
1982 from scapy.layers.kerberos import KerberosSSP
1983
1984 if not isinstance(self.ssp, KerberosSSP):
1985 raise ValueError("Only raw KerberosSSP is supported with SASL_GSSAPI !")
1986 elif mech == LDAP_BIND_MECHS.SASL_GSS_SPNEGO:
1987 from scapy.layers.spnego import SPNEGOSSP
1988
1989 if not isinstance(self.ssp, SPNEGOSSP):
1990 raise ValueError("Only SPNEGOSSP is supported with SASL_GSS_SPNEGO !")
1991 elif mech == LDAP_BIND_MECHS.SICILY:
1992 from scapy.layers.ntlm import NTLMSSP
1993
1994 if not isinstance(self.ssp, NTLMSSP):
1995 raise ValueError("Only raw NTLMSSP is supported with SICILY !")
1996 if self.sign and not self.encrypt:
1997 raise ValueError(
1998 "NTLM on LDAP does not support signing without encryption !"
1999 )
2000 elif mech in [LDAP_BIND_MECHS.NONE, LDAP_BIND_MECHS.SIMPLE]:
2001 if self.sign or self.encrypt:
2002 raise ValueError("Cannot use 'sign' or 'encrypt' with NONE or SIMPLE !")
2003 if self.ssp is not None and mech in [
2004 LDAP_BIND_MECHS.NONE,
2005 LDAP_BIND_MECHS.SIMPLE,

Callers 14

sniffMethod · 0.45
spawnMethod · 0.45
runMethod · 0.45
startMethod · 0.45
startMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45
_sr1_rtrequestFunction · 0.45
__init__Method · 0.45
__init__Method · 0.45
__bind_socketMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected