Wednesday, May 30, 2018

[Code Snippet] How to a create user in arcgis portal with a custom role?

Be The First To Comment
Create a user or add member in ArcGIS portal with a custom role -

1. Get all custom roles from the portal, I presumed that the portal already has custom roles other than (org_user, org_publisher, org_admin)

from arcgis.gis import *
gis= GIS(portalUrl, userName, password)
allRoles = gis.users.roles.all(max_roles=50)

2. Create a User with Default Role

username="test"
password=''
firstname='test_name'
lastname='test_last'
email='test@test.com'
description = 'Test Account'
role = 'org_publisher'
provider = 'enterprise'
idp_username = 'test'
level = 2
thumbnail = None

newUser = gis.users.create(username, password,firstname,
               lastname, email, description, role, provider, 
               idp_username, level, thumbnail)


3. Update  the defualt role to Custom Role - Assign the role object not role name

#Assigning the first role out of many portal roles, as an example
status = newUser.update_role(role=allRoles[0]
print(status)

If role assigned success, the value of status will be True.


Reference:
https://developers.arcgis.com/python/guide/accessing-and-managing-users/

Friday, May 25, 2018

[Code Snippet] Find Custom Role of users that are in ArcGIS portal - ArcGIS

Be The First To Comment
from arcgis.gis import *

self.portalInfo = GIS(self.portalUrl, self.userName, self.password)

self.portalUsers = self.portalInfo.users.search('')

users = self.portalUsers

roleManager = arcgis.gis.RoleManager(self.portalInfo)

roles = roleManager.all()

for user in users:

if hasattr(user,'roleId'):

for role in roles:

if(user.roleId == role.role_id):

print(user.username,user.role,role.name)

Remote debug environment setup for ArcGIS server extensions- SOE and SOI

Be The First To Comment
In order to debug the ArcGIS server extension SOE/SOI from your development machine, you have to follow 3 steps:
           1.       Enable remote debug ( Presumption is your development machine and GIS server are different machines)
           2.       Enable sever extension for debug
           3.       Attach debugger to the process running the service

Download and install the remote debuggin tools from - https://docs.microsoft.com/en-us/visualstudio/debugger/remote-debugging 

      A.  Enable remote debug
1.       Download and configure Remote tools on the development
a.       Find msvsmon.exe in the directory matching your version of Visual Studio. For Visual Studio 2015:

Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe
(x64 can debug both x86 and x64 but x86 can only debugs x86)

2.       On the remote computer,  copy Remote Debugger folder from development machine and put in C:\ drive. Then, run msvsmon.exe
3.       The msvsmon.exe output terminal shows
 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me