summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2011-03-27 16:38:16 -0400
committerRob Crittenden <rcritten@redhat.com>2011-03-29 13:45:40 -0400
commit509c772f13539e1f95362f7c31e02658abf425b1 (patch)
treeb7017abdaa00723513183633542cc6515733aeb6 /ipalib
parentbb9617f83867590eebef65e906f77094d1088afe (diff)
downloadfreeipa-509c772f13539e1f95362f7c31e02658abf425b1.tar.gz
freeipa-509c772f13539e1f95362f7c31e02658abf425b1.tar.xz
freeipa-509c772f13539e1f95362f7c31e02658abf425b1.zip
Fix gidnumber option of user-add command.
Ticket #1127
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/user.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index eaf24ce59..c3bcddd23 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -289,20 +289,22 @@ class user_add(LDAPCreate):
entry_attrs['homedirectory'] = home_dir
entry_attrs.setdefault('krbpwdpolicyreference', 'cn=global_policy,cn=%s,cn=kerberos,%s' % (api.env.realm, api.env.basedn))
- if ldap.has_upg():
- # User Private Groups - uidNumber == gidNumber
- entry_attrs['gidnumber'] = entry_attrs['uidnumber']
- else:
- # we're adding new users to a default group, get its gidNumber
- # get default group name from config
- def_primary_group = config.get('ipadefaultprimarygroup')
- group_dn = self.api.Object['group'].get_dn(def_primary_group)
- try:
- (group_dn, group_attrs) = ldap.get_entry(group_dn, ['gidnumber'])
- except errors.NotFound:
- error_msg = 'Default group for new users not found.'
- raise errors.NotFound(reason=error_msg)
- entry_attrs['gidnumber'] = group_attrs['gidnumber']
+ if 'gidnumber' not in entry_attrs:
+ # gidNumber wasn't specified explicity, find out what it should be
+ if ldap.has_upg():
+ # User Private Groups - uidNumber == gidNumber
+ entry_attrs['gidnumber'] = entry_attrs['uidnumber']
+ else:
+ # we're adding new users to a default group, get its gidNumber
+ # get default group name from config
+ def_primary_group = config.get('ipadefaultprimarygroup')
+ group_dn = self.api.Object['group'].get_dn(def_primary_group)
+ try:
+ (group_dn, group_attrs) = ldap.get_entry(group_dn, ['gidnumber'])
+ except errors.NotFound:
+ error_msg = 'Default group for new users not found.'
+ raise errors.NotFound(reason=error_msg)
+ entry_attrs['gidnumber'] = group_attrs['gidnumber']
if 'mail' in entry_attrs:
entry_attrs['mail'] = self.obj._normalize_email(entry_attrs['mail'], config)