mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-12 16:32:01 -05:00
Add ldap2 method to retrieve allowed attributes for specified objectClasses.
ldap2.get_allowed_attribute(['posixuser']) returns a list of unicode all lower case attribute names allowed for the object class 'posixuser'
This commit is contained in:
1 parent
b871b90ef0
commit
c9ab92f210
1 file changed
+17
-3
@@ -266,6 +266,16 @@ class ldap2(CrudBackend, Encoder):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_allowed_attributes(self, objectclasses):
|
||||||
|
if not self.schema:
|
||||||
|
return []
|
||||||
|
allowed_attributes = []
|
||||||
|
for oc in objectclasses:
|
||||||
|
obj = self.schema.get_obj(_ldap.schema.ObjectClass, oc)
|
||||||
|
if obj is not None:
|
||||||
|
allowed_attributes += obj.must + obj.may
|
||||||
|
return [unicode(a).lower() for a in list(set(allowed_attributes))]
|
||||||
|
|
||||||
def get_single_value(self, attr):
|
def get_single_value(self, attr):
|
||||||
"""
|
"""
|
||||||
Check the schema to see if the attribute is single-valued.
|
Check the schema to see if the attribute is single-valued.
|
||||||
@@ -597,15 +607,19 @@ class ldap2(CrudBackend, Encoder):
|
|||||||
Keyword arguments:
|
Keyword arguments:
|
||||||
attrs_list - list of attributes to return, all if None (default None)
|
attrs_list - list of attributes to return, all if None (default None)
|
||||||
"""
|
"""
|
||||||
return self.find_entries(None, attrs_list, dn, self.SCOPE_BASE, time_limit=time_limit, size_limit=size_limit, normalize=normalize)[0][0]
|
return self.find_entries(
|
||||||
|
None, attrs_list, dn, self.SCOPE_BASE, time_limit=time_limit,
|
||||||
|
size_limit=size_limit, normalize=normalize
|
||||||
|
)[0][0]
|
||||||
|
|
||||||
config_defaults = {'ipasearchtimelimit': [2], 'ipasearchrecordslimit': [0]}
|
config_defaults = {'ipasearchtimelimit': [2], 'ipasearchrecordslimit': [0]}
|
||||||
def get_ipa_config(self):
|
def get_ipa_config(self, attrs_list=None):
|
||||||
"""Returns the IPA configuration entry (dn, entry_attrs)."""
|
"""Returns the IPA configuration entry (dn, entry_attrs)."""
|
||||||
cdn = "%s,%s" % (api.Object.config.get_dn(), api.env.basedn)
|
cdn = "%s,%s" % (api.Object.config.get_dn(), api.env.basedn)
|
||||||
try:
|
try:
|
||||||
(cdn, config_entry) = self.find_entries(
|
(cdn, config_entry) = self.find_entries(
|
||||||
base_dn=cdn, scope=self.SCOPE_BASE, time_limit=2, size_limit=10
|
None, attrs_list, base_dn=cdn, scope=self.SCOPE_BASE,
|
||||||
|
time_limit=2, size_limit=10
|
||||||
)[0][0]
|
)[0][0]
|
||||||
except errors.NotFound:
|
except errors.NotFound:
|
||||||
config_entry = {}
|
config_entry = {}
|
||||||
|
|||||||
Reference in new issue
Block a user