Lines 46-58
from ldap.controls.readentry import PostReadControl, PreReadControl
|
Link Here
|
---|
|
46 |
from ldapurl import LDAPUrl, isLDAPUrl |
46 |
from ldapurl import LDAPUrl, isLDAPUrl |
47 |
|
47 |
|
48 |
import univention.logging # noqa: F401 |
48 |
import univention.logging # noqa: F401 |
49 |
from univention.config_registry import ConfigRegistry |
49 |
from univention.config_registry import ucr |
50 |
|
50 |
|
51 |
|
51 |
|
52 |
configRegistry = ConfigRegistry() |
|
|
53 |
configRegistry.load() |
54 |
feature_full_prepostread = configRegistry.is_true('directory/manager/feature/prepostread', False) |
55 |
|
56 |
try: |
52 |
try: |
57 |
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union # noqa: F401 |
53 |
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union # noqa: F401 |
58 |
except ImportError: |
54 |
except ImportError: |
Lines 102-109
def getRootDnConnection(start_tls=None, decode_ignorelist=[], reconnect=True):
|
Link Here
|
---|
|
102 |
:return: A LDAP access object. |
98 |
:return: A LDAP access object. |
103 |
:rtype: univention.uldap.access |
99 |
:rtype: univention.uldap.access |
104 |
""" |
100 |
""" |
105 |
ucr = ConfigRegistry() |
|
|
106 |
ucr.load() |
107 |
port = int(ucr.get('slapd/port', '7389').split(',')[0]) |
101 |
port = int(ucr.get('slapd/port', '7389').split(',')[0]) |
108 |
host = ucr['hostname'] + '.' + ucr['domainname'] |
102 |
host = ucr['hostname'] + '.' + ucr['domainname'] |
109 |
if ucr.get('ldap/server/type', 'dummy') == 'master': |
103 |
if ucr.get('ldap/server/type', 'dummy') == 'master': |
Lines 127-134
def getAdminConnection(start_tls=None, decode_ignorelist=[], reconnect=True):
|
Link Here
|
---|
|
127 |
:return: A LDAP access object. |
121 |
:return: A LDAP access object. |
128 |
:rtype: univention.uldap.access |
122 |
:rtype: univention.uldap.access |
129 |
""" |
123 |
""" |
130 |
ucr = ConfigRegistry() |
|
|
131 |
ucr.load() |
132 |
bindpw = open('/etc/ldap.secret').read().rstrip('\n') |
124 |
bindpw = open('/etc/ldap.secret').read().rstrip('\n') |
133 |
port = int(ucr.get('ldap/master/port', '7389')) |
125 |
port = int(ucr.get('ldap/master/port', '7389')) |
134 |
return access(host=ucr['ldap/master'], port=port, base=ucr['ldap/base'], binddn='cn=admin,' + ucr['ldap/base'], bindpw=bindpw, start_tls=start_tls, decode_ignorelist=decode_ignorelist, reconnect=reconnect) |
126 |
return access(host=ucr['ldap/master'], port=port, base=ucr['ldap/base'], binddn='cn=admin,' + ucr['ldap/base'], bindpw=bindpw, start_tls=start_tls, decode_ignorelist=decode_ignorelist, reconnect=reconnect) |
Lines 146-153
def getBackupConnection(start_tls=None, decode_ignorelist=[], reconnect=True):
|
Link Here
|
---|
|
146 |
:return: A LDAP access object. |
138 |
:return: A LDAP access object. |
147 |
:rtype: univention.uldap.access |
139 |
:rtype: univention.uldap.access |
148 |
""" |
140 |
""" |
149 |
ucr = ConfigRegistry() |
|
|
150 |
ucr.load() |
151 |
bindpw = open('/etc/ldap-backup.secret').read().rstrip('\n') |
141 |
bindpw = open('/etc/ldap-backup.secret').read().rstrip('\n') |
152 |
port = int(ucr.get('ldap/master/port', '7389')) |
142 |
port = int(ucr.get('ldap/master/port', '7389')) |
153 |
try: |
143 |
try: |
Lines 174-182
def getMachineConnection(start_tls=None, decode_ignorelist=[], ldap_master=True,
|
Link Here
|
---|
|
174 |
:return: A LDAP access object. |
164 |
:return: A LDAP access object. |
175 |
:rtype: univention.uldap.access |
165 |
:rtype: univention.uldap.access |
176 |
""" |
166 |
""" |
177 |
ucr = ConfigRegistry() |
|
|
178 |
ucr.load() |
179 |
|
180 |
bindpw = open(secret_file).read().rstrip('\n') |
167 |
bindpw = open(secret_file).read().rstrip('\n') |
181 |
|
168 |
|
182 |
if ldap_master: |
169 |
if ldap_master: |
Lines 264-272
class access(object):
|
Link Here
|
---|
|
264 |
|
251 |
|
265 |
self.port = int(port) if port else None |
252 |
self.port = int(port) if port else None |
266 |
|
253 |
|
267 |
ucr = ConfigRegistry() |
|
|
268 |
ucr.load() |
269 |
|
270 |
if self.start_tls is None: |
254 |
if self.start_tls is None: |
271 |
self.start_tls = ucr.get_int('directory/manager/starttls', 2) |
255 |
self.start_tls = ucr.get_int('directory/manager/starttls', 2) |
272 |
|
256 |
|
Lines 719-725
class access(object):
|
Link Here
|
---|
|
719 |
""" |
703 |
""" |
720 |
log.debug('uldap.add dn=%s', dn) |
704 |
log.debug('uldap.add dn=%s', dn) |
721 |
|
705 |
|
722 |
if feature_full_prepostread: |
706 |
if ucr.is_true('directory/manager/feature/prepostread', False): |
723 |
if serverctrls: |
707 |
if serverctrls: |
724 |
for ctrl in serverctrls: |
708 |
for ctrl in serverctrls: |
725 |
if isinstance(ctrl, PostReadControl): |
709 |
if isinstance(ctrl, PostReadControl): |
Lines 769-775
class access(object):
|
Link Here
|
---|
|
769 |
""" |
753 |
""" |
770 |
log.debug('uldap.modify %s', dn) |
754 |
log.debug('uldap.modify %s', dn) |
771 |
|
755 |
|
772 |
if feature_full_prepostread: |
756 |
if ucr.is_true('directory/manager/feature/prepostread', False): |
773 |
if serverctrls: |
757 |
if serverctrls: |
774 |
for ctrl in serverctrls: |
758 |
for ctrl in serverctrls: |
775 |
for ctrl_type in (PreReadControl, PostReadControl): |
759 |
for ctrl_type in (PreReadControl, PostReadControl): |
Lines 898-904
class access(object):
|
Link Here
|
---|
|
898 |
newrdn = ldap.dn.dn2str([ldap.dn.str2dn(newdn)[0]]) |
882 |
newrdn = ldap.dn.dn2str([ldap.dn.str2dn(newdn)[0]]) |
899 |
newsdn = ldap.dn.dn2str(ldap.dn.str2dn(newdn)[1:]) |
883 |
newsdn = ldap.dn.dn2str(ldap.dn.str2dn(newdn)[1:]) |
900 |
|
884 |
|
901 |
if feature_full_prepostread: |
885 |
if ucr.is_true('directory/manager/feature/prepostread', False): |
902 |
if serverctrls: |
886 |
if serverctrls: |
903 |
for ctrl in serverctrls: |
887 |
for ctrl in serverctrls: |
904 |
for ctrl_type in (PreReadControl, PostReadControl): |
888 |
for ctrl_type in (PreReadControl, PostReadControl): |
Lines 957-963
class access(object):
|
Link Here
|
---|
|
957 |
""" |
941 |
""" |
958 |
log.debug('uldap.delete %s', dn) |
942 |
log.debug('uldap.delete %s', dn) |
959 |
|
943 |
|
960 |
if feature_full_prepostread: |
944 |
if ucr.is_true('directory/manager/feature/prepostread', False): |
961 |
if serverctrls: |
945 |
if serverctrls: |
962 |
for ctrl in serverctrls: |
946 |
for ctrl in serverctrls: |
963 |
if isinstance(ctrl, PreReadControl): |
947 |
if isinstance(ctrl, PreReadControl): |