Unauthenticated LDAP requests
Do not use anonymous or unauthenticated authentication mechanisms with a blind LDAP client request because they allow unauthorized access without passwords.
def authenticate_connection_noncompliant():
    import ldap
    import os
    connect = ldap.initialize('ldap://127.0.0.1:1389')
    connect.set_option(ldap.OPT_REFERRALS, 0)
    # Noncompliant: authentication disabled.
    connect.simple_bind('cn=root')
def authenticate_connection_compliant():
    import ldap
    import os
    connect = ldap.initialize('ldap://127.0.0.1:1389')
    connect.set_option(ldap.OPT_REFERRALS, 0)
    # Compliant: simple security authentication used.
    connect.simple_bind('cn=root', os.environ.get('LDAP_PASSWORD'))