Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fountain
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
urz-django
fountain
Commits
d4ea0444
Commit
d4ea0444
authored
Dec 22, 2016
by
Daniel Klaffenbach
🐍
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fountain.ldap: Rework connection initialization
parent
c43de5db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
fountain/ldap.py
fountain/ldap.py
+15
-5
No files found.
fountain/ldap.py
View file @
d4ea0444
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
ssl
from
ldap3
import
Server
,
Connection
,
RESTARTABLE
from
ldap3
import
Server
,
Connection
,
RESTARTABLE
,
DSA
from
ldap3.core.tls
import
Tls
from
ldap3.utils.uri
import
parse_uri
from
django.conf
import
settings
...
...
@@ -29,11 +29,21 @@ class Ldap(object):
@
cached_property
def
connection
(
self
):
server_kwargs
=
{
'host'
:
self
.
LDAP_PARAMS
[
'host'
],
'use_ssl'
:
False
,
'port'
:
self
.
LDAP_PARAMS
[
'port'
]
}
if
self
.
LDAP_PARAMS
[
'ssl'
]:
tls
=
Tls
(
ca_certs_file
=
self
.
LDAP_CA_CERT
,
validate
=
ssl
.
CERT_REQUIRED
)
s
=
Server
(
self
.
LDAP_PARAMS
[
'host'
],
use_ssl
=
True
,
tls
=
tls
)
else
:
s
=
Server
(
self
.
LDAP_PARAMS
[
'host'
],
use_ssl
=
False
)
server_kwargs
[
'use_ssl'
]
=
True
server_kwargs
[
'tls'
]
=
Tls
(
ca_certs_file
=
self
.
LDAP_CA_CERT
,
validate
=
ssl
.
CERT_REQUIRED
)
# In case the LDAP server is the local host we assume a testing server.
# "SCHEMA" queries might not be available, so use "DSA" instead.
if
self
.
LDAP_PARAMS
[
'host'
]
==
'localhost'
:
server_kwargs
[
'get_info'
]
=
DSA
s
=
Server
(
**
server_kwargs
)
c
=
Connection
(
s
,
auto_bind
=
True
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment