HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //usr/share/doc/python-ldap-2.4.15/Demo/ms_ad_bind.py
# How to bind to MS AD with python-ldap and various methods

import ldap,ldap.sasl

ldap_uri = "ldap://dc1.example.com"
dn = "CN=Anna Blume,CN=Users,DC=addomain,DC=example,DC=com"
sAMAccountName = "ABlume"
userPrincipalName = "ablume@addomain.example.com"
password = 'testsecret'

trace_level = 2

l = ldap.initialize(ldap_uri,trace_level=trace_level)

# Normal LDAPv3 compliant simple bind
l.simple_bind_s(dn,password)

# This is AD-specific and not LDAPv3 compliant
l.simple_bind_s(userPrincipalName,password)

# This is AD-specific and not LDAPv3 compliant
l.simple_bind_s(userPrincipalName,password)

# SASL bind with mech DIGEST-MD5 with sAMAccountName as SASL user name
sasl_auth = ldap.sasl.sasl(
  {
    ldap.sasl.CB_AUTHNAME:sAMAccountName,
    ldap.sasl.CB_PASS    :password,
  },
  'DIGEST-MD5'
)
l.sasl_interactive_bind_s("", sasl_auth)

# SASL bind with mech GSSAPI
# with the help of Kerberos V TGT obtained before with command
# kinit ablume@ADDOMAIN.EXAMPLE.COM
sasl_auth = ldap.sasl.sasl({},'GSSAPI')
l.sasl_interactive_bind_s("", sasl_auth)