How to get information on which SAML group is used in a portal group?

843
4
Jump to solution
01-27-2022 01:51 AM
CarstenB_orsted
New Contributor III

 

I need to move groups from one enterprise portal to another. The groups are getting their members from SAML groups and I want to use the same SAML group on the target portal.

But I can't find any method in the API that returns which SAML group is used in the source group . I can get a list of users with group.get_members() or group.user_list() but not the SAML group.

I couldn't find anything in the REST API either.

The information is there, as you can edit it on the settings tab on the group.

Am I overlooking something obvious?

I'm using Enterprise 10.9.1 and ArcGIS API for Python 1.9.1

Update: I found two properties for groups,  provider and providerGroupName. If the group uses SAML , provider is set to 'enterprise', but providerGroupName is still None.

Also the isInvitationOnly property is False for groups using SAML

So at least now I can check whether SAML is used and give a warning that information should be updated manually. 

 

0 Kudos
1 Solution

Accepted Solutions
AzinSharaf
Occasional Contributor II

that is correct. providerGroupName returns None.

another way to get the providerGroupName using SAML is:

- get the group id using groupid properties

- build this url: group_url = f"https://portal_url/webadaptor/sharing/rest/community/groups/{group_id}"

- using urllib find the ProviderGroupName tag value from response. 

AzinSharaf_0-1643310425282.png

 

 

View solution in original post

4 Replies
AzinSharaf
Occasional Contributor II

that is correct. providerGroupName returns None.

another way to get the providerGroupName using SAML is:

- get the group id using groupid properties

- build this url: group_url = f"https://portal_url/webadaptor/sharing/rest/community/groups/{group_id}"

- using urllib find the ProviderGroupName tag value from response. 

AzinSharaf_0-1643310425282.png

 

 

CarstenB_orsted
New Contributor III

Hi Azin,

Thanks, I'll try it out as soon as possible. 

BTW: I just asked Esri support why the providerGroupName is None. I'll post updates here.

UPDATE: I couldn't wait trying it, even though it is late evening here. I get the information I need with the solution provided. Thanks again!

However, I think the information should be available through the ArcGIS API for Python!

Regards

Carsten

CarstenB_orsted
New Contributor III

Here's a couple of code snippets if anyone should need it.

Using the f=json parameter returns the response as json, making it very easy to parse.

First using the requests module

import requests

url =https://myserver.com/portal/sharing/rest/community/groups/{group_id}?f=pjson"

r = requests.get(url)
rjson = r.json()

provider = rjson["provider"]
providerGroupName = rjson["providerGroupName"]

print(provider)
print(providerGroupName)

And the the same thing, using urllib

from urllib.request import urlopen
import json

url = "https://myserver/portal/sharing/rest/community/groups/{group_id}?f=pjson"

r = urlopen(url)
rjson = json.loads(r.read())

provider = rjson["provider"]
providerGroupName = rjson["providerGroupName"]

print(provider)
print(providerGroupName)

 

ChrisBeaudette
Occasional Contributor

According to this thread this is a confirmed bug, but that page does provide a workaround for getting the group name via the python API:

from arcgis.gis import GIS

portal_url = "https://myorgportal.company.com/portal"
portal_username = "admin"
portal_password = "foo"

ent_gis = GIS(portal_url, portal_username, portal_password, verify_cert=False)
editing_groups = ent_gis.groups.search(query="tags:Edition",sort_field="title",sort_order="asc",outside_org=False)
for editing_group in editing_groups:
    edit_group = ent_gis.groups.get(editing_group["id"])
    print(edit_group.providerGroupName)

I confirmed that this works with ArcGIS Enterprise 10.9.1.