Created
January 4, 2021 15:24
-
-
Save tiran/4b56faf5a8b14b9828ef8ba2ad9292ba to your computer and use it in GitHub Desktop.
Revisions
-
tiran created this gist
Jan 4, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ #!/usr/bin/python3 import collections import configparser import time import socket import ldap import ldap.sasl SASL_GSSAPI = ldap.sasl.sasl({}, 'GSSAPI') SASL_GSS_SPNEGO = ldap.sasl.sasl({}, 'GSS-SPNEGO') METH = SASL_GSSAPI with open("/etc/ipa/default.conf") as f: cfg = configparser.RawConfigParser() cfg.read_file(f) URI = cfg.get("global", "ldap_uri") assert URI.startswith("ldapi://") def profile(uri, meth): conn = ldap.initialize(uri) conn.whoami_s() # start connection start = time.perf_counter() try: conn.sasl_interactive_bind_s('', meth) return time.perf_counter() - start finally: conn.unbind() # acquire service ticket profile(URI, METH) ctr = collections.Counter() for i in range(2000): dur = profile(URI, METH) dur = round(dur * 1000) ctr.update({dur: 1}) # print(f"{dur}ms") if dur > 500: c = "O" elif dur > 20: c = "x" else: c = "." print(c, end="", flush=True) print() for dur, count in sorted(ctr.items()): print(f"{dur}ms\t{count}")