{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Administration: Validate user profiles\n", "\n", "> * 👟 Ready To Run!\n", "* 🔒 Requires Administrator Privileges\n", "* 📝 Administration\n", "* 👤 User Management\n", "\n", "Some organizations require member profiles to contain values beyond the minumum required attributes necessary to create a valid user in an ArcGIS Online Organization or ArcGIS Enterprise. For instance, in order to comply with policies and regulations, an organization may require a profile picture or a brief description. This notebook will check attribute values for users of the organization to monitor profiles." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To get started, let's import the necessary libraries and connect to our GIS." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "import os\n", "import datetime as dt\n", "\n", "import pandas as pd\n", "\n", "from arcgis.gis import GIS\n", "\n", "gis = GIS(\"home\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then, let's create a list containing strings that represent all the values that your organization requires (beyond the required attributes for a valid user profile)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "complete_profile = ['description', 'thumbnail', 'access']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll define a function that loops through the list we created and inspects a user object for the values of these attributes. We'll create a list of True/False values for each user regarding the necessary attributes." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def get_missing_profile_attrs(member):\n", " non_compliance = []\n", " for attr in complete_profile:\n", " if getattr(member, attr) == None:\n", " non_compliance.append(False)\n", " else:\n", " non_compliance.append(True)\n", " return non_compliance" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can create a list of users in the GIS and loop through them, calling the function written above to inspect each user object. This will create a dictionary with usernames as the key and the list of True/False values regarding the required attributes as the values." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "user_profile_status = {}\n", "for user in gis.users.search(\"NOT esri_*\"):\n", " missing_profile_atts = get_missing_profile_attrs(user)\n", " user_profile_status[user.username] = missing_profile_atts" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pandas library can be used to create a dataframe from the above dictionary." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | description | \n", "thumbnail | \n", "access | \n", "
---|---|---|---|
user001 | \n", "False | \n", "False | \n", "True | \n", "
viewer002 | \n", "False | \n", "False | \n", "True | \n", "
primary_admin | \n", "False | \n", "False | \n", "True | \n", "
publisher001 | \n", "False | \n", "False | \n", "True | \n", "