Skip to content

Instantly share code, notes, and snippets.

@jvperrin
Created February 4, 2018 05:19
Show Gist options
  • Save jvperrin/866735be9421e0b4c7188af8024ddfef to your computer and use it in GitHub Desktop.
Save jvperrin/866735be9421e0b4c7188af8024ddfef to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import ldap3
import ssl
server = ldap3.Server('dev-ldap.ocf.berkeley.edu', use_ssl=True)
connection = ldap3.Connection(server, authentication=ldap3.SASL, sasl_mechanism='GSSAPI')
connection.bind()
print(connection.extend.standard.who_am_i())
connection.search(
'ou=People,dc=OCF,dc=Berkeley,dc=EDU',
'(uid=jvperrin)',
attributes=ldap3.ALL_ATTRIBUTES)
print(connection)
# response is []
print(connection.response)
# Full output is:
# dn:uid=jvperrin,ou=people,dc=ocf,dc=berkeley,dc=edu
# ldaps://dev-ldap.ocf.berkeley.edu:636 - ssl - user: None - not lazy - bound - open - <local: [2607:f140:8801::1:226]:45326 - remote: [2607:f140:8801::1:38]:636> - tls not started - listening - SyncStrategy - internal decoder
# []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment