summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/baseldap.py
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2009-12-10 16:39:24 +0100
committerRob Crittenden <rcritten@redhat.com>2010-01-11 13:28:05 -0500
commit74a538416999d84f7d3bd6cca4ab3655481ef848 (patch)
treee72e11e7092996946a439b6fd95cedf61e2fe2ba /ipalib/plugins/baseldap.py
parentb8016807ebb95b97f0a4631574be484371f4dcd0 (diff)
downloadfreeipa-74a538416999d84f7d3bd6cca4ab3655481ef848.tar.gz
freeipa-74a538416999d84f7d3bd6cca4ab3655481ef848.tar.xz
freeipa-74a538416999d84f7d3bd6cca4ab3655481ef848.zip
Add --all to LDAPCreate and make LDAP commands always display default attributes.
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r--ipalib/plugins/baseldap.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 94b006257..98da3ed64 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -135,6 +135,10 @@ class LDAPCreate(crud.Create):
doc='print entries as they are stored in LDAP',
exclude='webui',
),
+ Flag('all',
+ cli_name='all',
+ doc='retrieve all attributes',
+ ),
Str('addattr*', validate_add_attribute,
cli_name='addattr',
doc='Add an attribute/value pair. Format is attr=value',
@@ -170,11 +174,18 @@ class LDAPCreate(crud.Create):
if self.obj.uuid_attribute:
entry_attrs[self.obj.uuid_attribute] = str(uuid.uuid1())
- dn = self.pre_callback(ldap, dn, entry_attrs, *keys, **options)
+ if options.get('all', False):
+ attrs_list = ['*']
+ else:
+ attrs_list = list(
+ set(self.obj.default_attributes + entry_attrs.keys())
+ )
+
+ dn = self.pre_callback(ldap, dn, entry_attrs, attrs_list, *keys, **options)
ldap.add_entry(dn, entry_attrs)
- (dn, entry_attrs) = ldap.get_entry(dn, entry_attrs.keys())
+ (dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
dn = self.post_callback(ldap, dn, entry_attrs, *keys, **options)
@@ -204,7 +215,7 @@ class LDAPCreate(crud.Create):
else:
textui.print_dashed('Created %s.' % self.obj.object_name)
- def pre_callback(self, ldap, dn, entry_attrs, *keys, **options):
+ def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
return dn
def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
@@ -245,7 +256,7 @@ class LDAPRetrieve(LDAPQuery):
dn = self.obj.get_dn(*keys, **options)
- if options['all']:
+ if options.get('all', False):
attrs_list = ['*']
else:
attrs_list = list(self.obj.default_attributes)
@@ -307,10 +318,12 @@ class LDAPUpdate(LDAPQuery, crud.Update):
entry_attrs = self.args_options_2_entry(**options)
- if options['all']:
+ if options.get('all', False):
attrs_list = ['*']
else:
- attrs_list = entry_attrs.keys()
+ attrs_list = list(
+ set(self.obj.default_attributes + entry_attrs.keys())
+ )
dn = self.pre_callback(ldap, dn, entry_attrs, attrs_list, *keys, **options)
@@ -666,10 +679,12 @@ class LDAPSearch(crud.Search):
search_kw = self.args_options_2_entry(**options)
- if options['all']:
+ if options.get('all', False):
attrs_list = ['*']
else:
- attrs_list = self.obj.default_attributes + search_kw.keys()
+ attrs_list = list(
+ set(self.obj.default_attributes + search_kw.keys())
+ )
search_kw['objectclass'] = self.obj.object_class
attr_filter = ldap.make_filter(search_kw, rules=ldap.MATCH_ALL)
@@ -740,3 +755,4 @@ class LDAPSearch(crud.Search):
def post_callback(self, ldap, entries, truncated, *args, **options):
pass
+