Python - flask_simpleldap will not bind

I am using flask_simpleldap and am struggling to get a connecting connection to do something useful.

My LDAP server is the active directory.

The stripped-down code looks like this and looks almost identical to the example :

from flask import Flask
from flask_simpleldap import LDAP

app = Flask(__name__)
app.secret_key = 'super secret key'
app.debug = True

app.config['LDAP_HOST'] = 'my-ldap-host.example.com'
app.config['LDAP_REALM_NAME'] = 'LDAP Authentication'
app.config['LDAP_SCHEMA'] = 'ldaps'
app.config['LDAP_PORT'] = 636
app.config['LDAP_BASE_DN'] = 'dc=example,dc=com'
app.config['LDAP_USERNAME'] = 'binduser@example.com'
app.config['LDAP_PASSWORD'] = 'binduser_pw'

app.config['LDAP_OBJECTS_DN'] = 'distinguishedName'
app.config['LDAP_OPENLDAP'] = False

ldap = LDAP(app)


@app.route('/ldap')
@ldap.basic_auth_required
def ldap_protected():
    return 'Welcome, {0}!'.format(g.ldap_username)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080, debug=True)

When starting the flash application, I get an error message:

LDAPException: Operations error

While trying to troubleshoot, I changed the file flask_simpleldap __init__.pyto show info, as well as descerrors, on line 274 ; Now I get a little more error info:

LDAPException: 000004DC: LdapErr: DSID-0C090752, 
comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580

So, I think I need to understand why my initial binding will not work ... do I have something wrong with mine app.config?

, ... ldapsearch, , :

ldapsearch -x -LLL -E pr=200/noprompt -h my-ldap-host.example.com -D "binduser@example.com" -w 'binduser_pw' -b "dc=example, dc=com" -s sub  "(sAMAccountName=binduser)"    | grep distinguishedName


distinguishedName: CN=Bind User,OU=Some_OU,DC=example,DC=com

:

  • python2.7 3.5,
  • Centos 7.2
  • Active Directory - LDAP

, .

+1
2

, , flask_simpleldap Active Directory. , :

app.config['LDAP_USE_SSL'] = True

, " ", DN username.

+1

.

app.config['LDAP_USERNAME'] = 'uid=binduser,dc=example,dc=com'
+1

All Articles