Last active
September 2, 2016 21:13
-
-
Save arnobroekhof/017692c3a03a69f522a00521710e0192 to your computer and use it in GitHub Desktop.
Python script for binding to ldap using kerbers and showing the authenticated users attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Make sure the python-ldap module is installed | |
# pip install python-ldap | |
import ldap | |
import ldap.sasl | |
#Initialize your connection and force it to use TLS | |
con = ldap.initialize('ldap://ldap.example.com') | |
con.set_option(ldap.OPT_X_TLS_DEMAND, True) | |
con.start_tls_s() | |
#Configure auth to use GSSAPI | |
auth = ldap.sasl.gssapi("") | |
#Actually make the connection | |
con.sasl_interactive_bind_s("", auth) | |
result = con.search_s(con.whoami_s()[3:],ldap.SCOPE_SUBTREE) | |
print result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment