Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1489367

Summary: [Hammer] Org Admin user cannot create user though cli
Product: Red Hat Satellite Reporter: Jitendra Yejare <jyejare>
Component: Organizations and LocationsAssignee: Marek Hulan <mhulan>
Status: CLOSED ERRATA QA Contact: Corey Welton <cwelton>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: akofink, bbuckingham, cwelton, dhlavacd, dlobatog, egolov, mhulan
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1502725 (view as bug list) Environment:
Last Closed: 2018-02-21 17:31:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1373844    

Description Jitendra Yejare 2017-09-07 09:34:10 UTC
Description of problem:
An Org Admin user cannot create another user through hammer CLI, throws exception- 
"Organization ids Invalid organizations selection, you must select at least one of yours"

Version-Release number of selected component (if applicable):
Satellite 6.3.0 snap 14

How reproducible:
Always

Steps to Reproduce:
1. Create Org Admin role and assign any taxonomies to it
2. Create user and assign above Org Admin role to it and same taxonomies
3. Login with above Org Admin user
4. Attempt to create new users


Actual Results:

Try any of the following

# hammer user create --auth-source-id 1 --login user3_from1 --mail use.r3 --password passwd
-> Organization ids Invalid organizations selection, you must select at least one of yours
  Location ids Invalid locations selection, you must select at least one of yours

# hammer user create --auth-source-id 1 --login user3_from1 --mail use.r3 --password passwd --organization-ids 1
Could not create the user:
  Organization ids Invalid organizations selection, you must select at least one of yours
  Location ids Invalid locations selection, you must select at least one of yours

# hammer user create --auth-source-id 1 --login user3_from1 --mail use.r3 --password passwd --location-ids 2
Could not create the user:
  Organization ids Invalid organizations selection, you must select at least one of yours

# hammer user create --auth-source-id 1 --login user3_from1 --mail use.r3 --password passwd --location-ids 2 --organization-ids 1
Could not create the user:
  Organization ids Invalid organizations selection, you must select at least one of yours

Expected results:
User should be created through Org Admin user

Additional info:

Comment 3 Marek Hulan 2017-09-12 05:53:37 UTC
I'll try to reproduce. From quick read I think only the last command should succeed. New user must have orgs and locs set.

Comment 4 Andrew Kofink 2017-09-21 12:48:48 UTC
I am able to reproduce.

Comment 5 Andrew Kofink 2017-09-21 14:22:38 UTC
So, I guess the real question is, should the 'Organization admin' role contain the 'assign_organizations' permission?

Comment 7 Marek Hulan 2017-09-25 14:44:02 UTC
I don't think org admin should has such permission. The use case is that we have a user who is "org admin of $org", the $org should be auto-assigned to the resource. I think UI does it automatically, API needs to start doing it too. I'll try to look at it this week but I'm offline next week. If you want to look at that, just please ping me and retake :-)

Comment 8 Marek Hulan 2017-09-26 17:59:31 UTC
This is another org and locs issue, this time for the whole API. No API call sets current organization or location. The reason was that hammer did not support sessions and there's no generic API parameter to set it.

One part of the solution is to take the set_taxonomy before filter from UI application controller and put it into application_shared concern. That should ensure that for non-admin user, first available taxonoy is selected.

Second part is calling set_user_taxonomies from UserMixin after api login happens in order for user to be able to modify in which context he or she works. Otherwise it would always select the first one.

Later I could imagine adding --current-organization override argument but that wuld require more changes.

Comment 9 Marek Hulan 2017-09-27 08:58:56 UTC
Created redmine issue http://projects.theforeman.org/issues/21119 from this bug

Comment 10 Satellite Program 2017-09-27 10:14:02 UTC
Upstream bug assigned to mhulan

Comment 11 Satellite Program 2017-09-27 10:14:06 UTC
Upstream bug assigned to mhulan

Comment 17 Corey Welton 2017-10-23 17:19:53 UTC
Verified in snap 21

[root@yttrium ~]# hammer user create --auth-source-id 1 --login permutation1 --mail use.r3 --password passwd
User [permutation1] created
[root@yttrium ~]# hammer user create --auth-source-id 1 --login permutation2 --mail use.r3 --password passwd --organization-ids 1
User [permutation2] created
[root@yttrium ~]# hammer user create --auth-source-id 1 --login permutation3 --mail use.r3 --password passwd --location-ids 2
User [permutation3] created
[root@yttrium ~]# hammer user create --auth-source-id 1 --login permutation4 --mail use.r3 --password passwd --location-ids 2 --organization-ids 1
User [permutation4] created

Comment 18 Bryan Kearney 2018-02-21 17:31:06 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.

For information on the advisory, and where to find the updated files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336