mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
jwutils.ldap: Add module
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
e4cee86482
commit
1e43cdc715
2 changed files with 300 additions and 17 deletions
|
|
@ -5,7 +5,7 @@ from typing import Optional, Union
|
|||
import ldap
|
||||
|
||||
from ...log import *
|
||||
from ... import Config
|
||||
from ...ldap import bind
|
||||
from .. import Access
|
||||
from .. import Auth as AuthBase
|
||||
from .. import Group as GroupBase
|
||||
|
|
@ -62,22 +62,7 @@ class Auth(AuthBase): # export
|
|||
self.__dummy = self.load('dummy', conf)
|
||||
|
||||
def __bind(self):
|
||||
ldap_uri = self.conf['ldap_uri']
|
||||
bind_dn = self.conf['bind_dn']
|
||||
bind_pw = self.conf.get('password')
|
||||
if bind_pw is None:
|
||||
with open(ldap_secret_file, 'r') as file:
|
||||
bind_pw = file.read()
|
||||
file.closed
|
||||
bind_pw = bind_pw.strip()
|
||||
ret = ldap.initialize(ldap_uri)
|
||||
ret.start_tls_s()
|
||||
try:
|
||||
rr = ret.bind_s(bind_dn, bind_pw) # method)
|
||||
except Exception as e:
|
||||
#pw = f' (pw={bind_pw})'
|
||||
raise Exception(f'Failed to bind to {ldap_uri} with dn {bind_dn} ({e})')
|
||||
return ret
|
||||
return bind(self.conf)
|
||||
|
||||
@property
|
||||
def __users(self) -> User:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue