making some attributes explicitly mandatory for Active Directory backend

This commit is contained in:
kakwa 2016-06-16 22:32:44 +02:00
parent 9a882d3626
commit d8631da7ba
1 changed files with 11 additions and 1 deletions

View File

@ -23,12 +23,16 @@ class CaFileDontExist(Exception):
self.log = "CA file %(cafile)s don't exist" % {'cafile': cafile}
class MissingAttr(Exception):
def __init__(self):
self.log = 'attributes "cn" and "unicodePwd" must be declared ' \
'in attributes.yml for all Active Directory backends.'
NO_ATTR = 0
DISPLAYED_ATTRS = 1
LISTED_ATTRS = 2
ALL_ATTRS = 3
# UserAccountControl Attribute/Flag Values
# For details, look at:
# https://support.microsoft.com/en-us/kb/305144
@ -139,6 +143,12 @@ class Backend(ldapcherry.backend.backendLdap.Backend):
for a in attrslist:
self.attrlist.append(self._str(a))
if 'cn' not in self.attrlist:
raise MissingAttr()
if 'unicodePwd' not in self.attrlist:
raise MissingAttr()
def _search_group(self, searchfilter, groupdn):
searchfilter = self._str(searchfilter)
ldap_client = self._bind()