Advertisement
savsanta

ldap-tester-sysforum.py

Apr 7th, 2019
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.68 KB | None | 0 0
  1. #! /usr/bin/env python
  2.  
  3. # LDAP Test Using ForumSys Online LDAP
  4. # https://www.python-ldap.org/en/python-ldap-3.2.0/bytes_mode.html - Highlights Differences Between Python3 and Python2. This intends python2
  5. # https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
  6. # http://core.tcl.tk/tcllib/doc/tcllib-1-16/embedded/www/tcllib/files/modules/ldap/ldap.html
  7. # Python for Unix and Linux Administrators book also a good refenence
  8.  
  9.  
  10. import ldap
  11.  
  12. # Port 389 is not using secured. Also I've seen some versions of ldap have an ldap.open(). Didnt work for me
  13.  
  14. con = ldap.initialize("ldap://ldap.forumsys.com:389")
  15.  
  16. # This is to bind to the simple Mathemeticians OU. However website says one can sub in "cn=read-only-admin" or "ou=scientists" with the same password.
  17.  
  18. con.simple_bind_s('ou=mathematicians,dc=example,dc=com','password')
  19.  
  20. # Make a query and save the results
  21. results = con.search_s('cn=read-only-admin,dc=example,dc=com', ldap.SCOPE_SUBTREE)
  22.  
  23.  
  24. # The equivalent modifiable linux ldapsearch CLI tool command is approximately:
  25. # ldapsearch -W -h ldap.forumsys.com -D "uid=tesla,dc=example,dc=com" -b "dc=example,dc=com"
  26.  
  27. #
  28. image_in_base64 = "/9j/4AAQSkZJRgABAQIAHAAcAAD/2wBDACAWGBwYFCAcGhwkIiAmMFA0MCwsMGJGSjpQdGZ6eHJmcG6AkLicgIiuim5woNqirr7EztDOfJri8uDI8LjKzsb/wAALCADDAP4BAREA/8QAGgABAAMBAQEAAAAAAAAAAAAAAAECAwQFBv/EADUQAAICAQMDAgQEBQQDAQAAAAECABEDBBIhEzFRQaEUImFxMoGRsQVCwdHwFTNS4SNy8cL/2gAIAQEAAD8A+giIiIiZZMWM27gjjkhiP2mWFMGUsArgr3DMf7zqiIiIiIiIiIiIiIiIiIiJnnNYm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