How to get license level from arcgis portal login

1087
4
Jump to solution
11-26-2018 06:25 AM
YMSSK
by
New Contributor II

Hi,

I am using LicenseInfo by authenticating user to arcgis poral. The code is like this (copied from some sample):

                // Create a challenge request for portal credentials (OAuth credential request for arcgis.com)
                CredentialRequestInfo challengeRequest = new CredentialRequestInfo();

                // Use the OAuth implicit grant flow
                challengeRequest.GenerateTokenOptions = new GenerateTokenOptions
                {
                    //TokenAuthenticationType = TokenAuthenticationType.OAuthImplicit
                    TokenAuthenticationType = TokenAuthenticationType.ArcGISToken
                };

                // Indicate the url (portal) to authenticate with (ArcGIS Online)
                challengeRequest.ServiceUri = new Uri(this.PortalAccount.PortalUrl);

                //// Call GetCredentialAsync on the AuthenticationManager to invoke the challenge handler
                //await AuthenticationManager.Current.GetCredentialAsync(challengeRequest, false);

                // Call GetCredentialAsync on the AuthenticationManager to invoke the challenge handler
                Credential cred = await AuthenticationManager.Current.GetCredentialAsync(challengeRequest, false);


                // Call GetCredentialAsync on the AuthenticationManager to invoke the challenge handler
                // Credential cred = await AuthenticationManager.Current.GetCredentialAsync(loginInfo, false);

                // Connect to the portal(ArcGIS Online) using the credential
                ArcGISPortal arcgisPortal = await ArcGISPortal.CreateAsync(challengeRequest.ServiceUri, cred);

                Esri.ArcGISRuntime.LicenseInfo licenseInfo = arcgisPortal.PortalInfo.LicenseInfo;

So I have PortalUser object (arcgisPortal.User ) and LicenseInfo object and I would like to know what kind of license user has (lite or basic) or at least if that user is Level1 or Level2 portal user. I just can't find it there. How can I find it ?

Thank you.

1 Solution

Accepted Solutions
JoeHershman
MVP Regular Contributor

If that is not giving enough information your only option is hitting the rest API directly using HttpClient.  That will give all the information available (Portal services ).  Make a call to 

https://[domainurl]/portal/sharing/rest/community/users/[username]?f=json and you will get a big json object with everything about the user.

As far as knowing the actual level of the Runtime license I don't know.  I have always used named user approach to get a license and not used an embedded license  

Thanks,
-Joe

View solution in original post

4 Replies
JoeHershman
MVP Regular Contributor

PortalUser.Privileges Property.  Gives you an iteration of the PortalPrivilege Class.  From there get the PortalPrivilege Class object and the PortalPrivilege.Role Property should give you want you want

Thanks,
-Joe
0 Kudos
YMSSK
by
New Contributor II

Thank you for the answer, but I am afraid that,  it didn't help me find info about license level or named user level. In PortalUser.Privileges there is a list of privileges concerning portal activity, like editing features, creating groups, etc. I have checked them all, but could not find information about my license level. I need this information because I wish to expose certain functions only to users who have basic arcgis runtime licence (named user level 2 on portal).

0 Kudos
JoeHershman
MVP Regular Contributor

If that is not giving enough information your only option is hitting the rest API directly using HttpClient.  That will give all the information available (Portal services ).  Make a call to 

https://[domainurl]/portal/sharing/rest/community/users/[username]?f=json and you will get a big json object with everything about the user.

As far as knowing the actual level of the Runtime license I don't know.  I have always used named user approach to get a license and not used an embedded license  

Thanks,
-Joe
YMSSK
by
New Contributor II

That portal service did the trick. There is information about Named user level.

I am using named user approach to get license as well, but I wish to disable certain functionality for user with lower license (level 1 named users), so I needed to know level of logged named user.

Thank you very much, that helped a lot.

0 Kudos