<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ISE Internal user creation using Python script in Network Access Control</title>
    <link>https://community.cisco.com/t5/network-access-control/ise-internal-user-creation-using-python-script/m-p/4397145#M567100</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create internal users using Python script.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have installed 3.9.2 Python and saved the .py file and run the execution using ERS SDK guide for ISE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However getting an error:-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C:\Users\ghibuser\Desktop&amp;gt;python ISEInternalUserTest.py 192.xxxxxx ers-admin admin20 B100 robert Robert Mensah Password1 rmensah@gh.co.uk Employee 12/26/2021&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;File "C:\Users\ghibuser\Desktop\ISEInternalUserTest.py", line 38, in &amp;lt;module&amp;gt;&lt;BR /&gt;req_body_json = """{{&lt;BR /&gt;IndexError: Replacement index 8 out of range for positional args tuple&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is my code&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#!/usr/bin/python&lt;BR /&gt;import http.client&lt;BR /&gt;import base64&lt;BR /&gt;import ssl&lt;BR /&gt;import sys&lt;BR /&gt;import os&lt;BR /&gt;import urllib3&lt;/P&gt;&lt;P&gt;urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;argv = sys.argv[1]&lt;BR /&gt;print ("The name of the script: ", sys.argv[0])&lt;BR /&gt;print ("The argument are: ", argv)&lt;BR /&gt;#parameters&lt;/P&gt;&lt;P&gt;id = sys.argv[4] # "B100"&lt;BR /&gt;userName = sys.argv[5] # "robert"&lt;BR /&gt;firstName = sys.argv[6] # "Robert"&lt;BR /&gt;lastName = sys.argv[7] # " Mensah"&lt;BR /&gt;password = sys.argv[8] # "Password1"&lt;BR /&gt;emailAddress = sys.argv[9] # "rmensah@gh.co.uk&lt;BR /&gt;expiryDate = sys.argv[10] # “12/26/2022”&lt;BR /&gt;identityGroups = sys.argv[11] # “Employee”&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# host and authentication credentials&lt;BR /&gt;host = sys.argv[1] # "192.198.1.1"&lt;BR /&gt;user = sys.argv[2] # “ers.admin”&lt;BR /&gt;password = sys.argv[3] # “admin20!”&lt;/P&gt;&lt;P&gt;conn = http.client.HTTPSConnection("{}:9060".format(host), context=ssl.SSLContext(ssl.PROTOCOL_TLS))&lt;/P&gt;&lt;P&gt;creds = str.encode(':'.join((user, password)))&lt;BR /&gt;encodedAuth = bytes.decode(base64.b64encode(creds))&lt;/P&gt;&lt;P&gt;req_body_json = """{{&lt;/P&gt;&lt;P&gt;\"InternalUser\" : {{&lt;/P&gt;&lt;P&gt;\"id"\ : "\{}\",&lt;BR /&gt;&lt;BR /&gt;\"Name\" : "\{}\",&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;\"description"\ : "\{}\",&lt;/P&gt;&lt;P&gt;"enabled" : true,&lt;/P&gt;&lt;P&gt;\"email\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"password\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"firstName\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"lastName\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"changePassword\" : true,&lt;/P&gt;&lt;P&gt;\"identityGroups\" : "\{}\",&lt;/P&gt;&lt;P&gt;"expiryDateEnabled" : false,&lt;/P&gt;&lt;P&gt;"expiryDate" : "\{}\",&lt;/P&gt;&lt;P&gt;"enablePassword" : "enablePassword",&lt;/P&gt;&lt;P&gt;"customAttributes" : {&lt;/P&gt;&lt;P&gt;"key1" : "value1",&lt;/P&gt;&lt;P&gt;"key2" : "value3"&lt;/P&gt;&lt;P&gt;},&lt;/P&gt;&lt;P&gt;"passwordIDStore" : "Internal Users"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}}&lt;BR /&gt;}}""".format(id,userName,firstName,lastName,emailAddress,password,identityGroups,expiryDate)&lt;BR /&gt;headers = {&lt;BR /&gt;'accept': "application/json",&lt;BR /&gt;'content-type': "application/json",&lt;BR /&gt;'authorization': " ".join(("Basic",encodedAuth)),&lt;BR /&gt;'cache-control': "no-cache",&lt;BR /&gt;}&lt;BR /&gt;conn.request("POST", "/ers/config/internaluser/", headers=headers, body=req_body_json)&lt;BR /&gt;&lt;BR /&gt;es = conn.getresponse()&lt;BR /&gt;data = res.read()&lt;/P&gt;&lt;P&gt;print("Status: {}".format(res.status))&lt;BR /&gt;print("Header:\n{}".format(res.headers))&lt;BR /&gt;print("Body:\n{}".format(data.decode("utf-8")))&lt;/P&gt;&lt;P&gt;print(req_body_json)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Any help would be appreciated!!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Richard Acolatse&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 03 May 2021 16:34:33 GMT</pubDate>
    <dc:creator>RichardAcolatse8417</dc:creator>
    <dc:date>2021-05-03T16:34:33Z</dc:date>
    <item>
      <title>ISE Internal user creation using Python script</title>
      <link>https://community.cisco.com/t5/network-access-control/ise-internal-user-creation-using-python-script/m-p/4397145#M567100</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create internal users using Python script.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have installed 3.9.2 Python and saved the .py file and run the execution using ERS SDK guide for ISE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However getting an error:-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C:\Users\ghibuser\Desktop&amp;gt;python ISEInternalUserTest.py 192.xxxxxx ers-admin admin20 B100 robert Robert Mensah Password1 rmensah@gh.co.uk Employee 12/26/2021&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;File "C:\Users\ghibuser\Desktop\ISEInternalUserTest.py", line 38, in &amp;lt;module&amp;gt;&lt;BR /&gt;req_body_json = """{{&lt;BR /&gt;IndexError: Replacement index 8 out of range for positional args tuple&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is my code&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#!/usr/bin/python&lt;BR /&gt;import http.client&lt;BR /&gt;import base64&lt;BR /&gt;import ssl&lt;BR /&gt;import sys&lt;BR /&gt;import os&lt;BR /&gt;import urllib3&lt;/P&gt;&lt;P&gt;urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;argv = sys.argv[1]&lt;BR /&gt;print ("The name of the script: ", sys.argv[0])&lt;BR /&gt;print ("The argument are: ", argv)&lt;BR /&gt;#parameters&lt;/P&gt;&lt;P&gt;id = sys.argv[4] # "B100"&lt;BR /&gt;userName = sys.argv[5] # "robert"&lt;BR /&gt;firstName = sys.argv[6] # "Robert"&lt;BR /&gt;lastName = sys.argv[7] # " Mensah"&lt;BR /&gt;password = sys.argv[8] # "Password1"&lt;BR /&gt;emailAddress = sys.argv[9] # "rmensah@gh.co.uk&lt;BR /&gt;expiryDate = sys.argv[10] # “12/26/2022”&lt;BR /&gt;identityGroups = sys.argv[11] # “Employee”&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# host and authentication credentials&lt;BR /&gt;host = sys.argv[1] # "192.198.1.1"&lt;BR /&gt;user = sys.argv[2] # “ers.admin”&lt;BR /&gt;password = sys.argv[3] # “admin20!”&lt;/P&gt;&lt;P&gt;conn = http.client.HTTPSConnection("{}:9060".format(host), context=ssl.SSLContext(ssl.PROTOCOL_TLS))&lt;/P&gt;&lt;P&gt;creds = str.encode(':'.join((user, password)))&lt;BR /&gt;encodedAuth = bytes.decode(base64.b64encode(creds))&lt;/P&gt;&lt;P&gt;req_body_json = """{{&lt;/P&gt;&lt;P&gt;\"InternalUser\" : {{&lt;/P&gt;&lt;P&gt;\"id"\ : "\{}\",&lt;BR /&gt;&lt;BR /&gt;\"Name\" : "\{}\",&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;\"description"\ : "\{}\",&lt;/P&gt;&lt;P&gt;"enabled" : true,&lt;/P&gt;&lt;P&gt;\"email\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"password\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"firstName\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"lastName\" : "\{}\",&lt;/P&gt;&lt;P&gt;\"changePassword\" : true,&lt;/P&gt;&lt;P&gt;\"identityGroups\" : "\{}\",&lt;/P&gt;&lt;P&gt;"expiryDateEnabled" : false,&lt;/P&gt;&lt;P&gt;"expiryDate" : "\{}\",&lt;/P&gt;&lt;P&gt;"enablePassword" : "enablePassword",&lt;/P&gt;&lt;P&gt;"customAttributes" : {&lt;/P&gt;&lt;P&gt;"key1" : "value1",&lt;/P&gt;&lt;P&gt;"key2" : "value3"&lt;/P&gt;&lt;P&gt;},&lt;/P&gt;&lt;P&gt;"passwordIDStore" : "Internal Users"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}}&lt;BR /&gt;}}""".format(id,userName,firstName,lastName,emailAddress,password,identityGroups,expiryDate)&lt;BR /&gt;headers = {&lt;BR /&gt;'accept': "application/json",&lt;BR /&gt;'content-type': "application/json",&lt;BR /&gt;'authorization': " ".join(("Basic",encodedAuth)),&lt;BR /&gt;'cache-control': "no-cache",&lt;BR /&gt;}&lt;BR /&gt;conn.request("POST", "/ers/config/internaluser/", headers=headers, body=req_body_json)&lt;BR /&gt;&lt;BR /&gt;es = conn.getresponse()&lt;BR /&gt;data = res.read()&lt;/P&gt;&lt;P&gt;print("Status: {}".format(res.status))&lt;BR /&gt;print("Header:\n{}".format(res.headers))&lt;BR /&gt;print("Body:\n{}".format(data.decode("utf-8")))&lt;/P&gt;&lt;P&gt;print(req_body_json)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Any help would be appreciated!!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Richard Acolatse&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 16:34:33 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/ise-internal-user-creation-using-python-script/m-p/4397145#M567100</guid>
      <dc:creator>RichardAcolatse8417</dc:creator>
      <dc:date>2021-05-03T16:34:33Z</dc:date>
    </item>
  </channel>
</rss>

