[Python] Errors when trying to use python-ldap with SASL GSSAPI

Discussão em 'Python' iniciado por Stack, Junho 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to connect and bind with ldap using SASL GSSAPI using the python-ldap library. It works fine with binding username and password. However I am experiencing several issues when trying different methods to bind using kytab which results in different errors. I have checked and client and server support kerberos keytab. I have also tried setting environment variables for KRB5_CLIENT_KTNAME, KRB5CCNAME and keytab but still the issue persists.

    Below gives the error

    File "python/site-packages/ldap/ldapobject.py", line 270 in sasl_interactive_bind_s
    return self._ldap_call(self._l.sasl_interactive_bind_s,who,auth,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls),sasl_flags)
    File "python/site-packages/ldap/controls/__init__.py", line 118, in RequestControlTuples
    for c in ldapControls
    TypeError: 'gssapi' object is not iterable

    a=ldap.sasl.gssapi()
    conn.sasl_non_interactive_bind_s("GSSAPI", a)


    I tried alternatives with the below methods and get "Unknown authentication method. SASL no mechanism available. No worthy mechs found."

    server = 'ldap://server.domain.tld'
    sasl_auth = ldap.sasl.sasl({} ,'GSSAPI')
    conn = ldap.initialize(server, trace_level=0)
    conn.set_option(ldap.OPT_REFERRALS,0)
    conn.protocol_version = ldap.VERSION3
    conn.sasl_interactive_bind_s("", sasl_auth)


    Another method with same results I tried

    conn.sasl_gssapi_bind_s(authz_id="...")

    Continue reading...

Compartilhe esta Página