04-29-2021 03:23 AM
I want to how i can connect to a Cisco ISE on VPN network with a python API script
Solved! Go to Solution.
04-29-2021 04:55 AM
Please see/use the following resources as they will provide great examples:
ISE ERS API Examples - Cisco Community
Online ISE SDK - https://<ISE-ADMIN-NODE>:9060/ers/sdk
04-29-2021 04:55 AM
Please see/use the following resources as they will provide great examples:
ISE ERS API Examples - Cisco Community
Online ISE SDK - https://<ISE-ADMIN-NODE>:9060/ers/sdk
05-02-2021 10:09 AM - edited 05-03-2021 03:27 AM
Hi Mike
I am try to create internal users with my Python script for Cisco ISE This is my code I created
#!/usr/bin/python
import http.client
import base64
import ssl
import sys
import os
argv = sys.argv[1]
print ("The name of the script: ", sys.argv[0])
print ("The argument are: ", argv)
#parameters
Id = sys.argv[4] # "B100"
userName = sys.argv[5] # "Robert"
firstName = sys.argv[6] # "Robert"
lastName = sys.argv[7] # "Mensah"
password = sys.argv[8] # "Password1"
emailAddress = sys.argv[9] # "rmensah@cisco.com
expiryDate = sys.argv[11] # “12/26/2020”
identityGroups = sys.argv[10] # “identityGroups”
# host and authentication credentials
host = sys.argv[1] # "192.198”.1.1
user = sys.argv[2] # “ers-admin”
password = sys.argv[3] # “admin20!”
conn = http.client.HTTPSConnection("{}:9060".format(host), context=ssl.SSLContext(ssl.PROTOCOL_TLS))
creds = str.encode(':'.join((user, password)))
encodedAuth = bytes.decode(base64.b64encode(creds))
req_body_json = """{{
\"InternalUser"\ : {
"id" : "\{}\",
"userName" : "\{}\",
"description" : "\{}\",
"enabled" : true,
"email" : "\{}\",
"password" : "\{}\",
"firstName" : "\{}\",
"lastName" : "\{}\",
"changePassword" : true,
"identityGroups" : "\{}\",
"expiryDateEnabled" : false,
"expiryDate" : "\{}\",
"enablePassword" : "enablePassword",
"customAttributes" : {
"key1" : "value1",
"key2" : "value3"
},
"passwordIDStore" : "Internal Users"
}
}}
}}""".format(Id,UserNname,firstName,lastName,emailAddress,password,identityGroups,expiryDate)
headers = {
'accept': "application/json",
'content-type': "application/json",
'authorization': " ".join(("Basic",encodedAuth)),
'cache-control': "no-cache",
}
conn.request("POST", "/ers/config/internaluser/", headers=headers, body=req_body_json)
es = conn.getresponse()
data = res.read()
print("Status: {}".format(res.status))
print("Header:\n{}".format(res.headers))
print("Body:\n{}".format(data.decode("utf-8")))
print (req_req_json)
I got this error while executing the above code
Traceback (most recent call last):
File "C:\Users\ghibuser\Desktop\ISEInternalUserTest.py", line 38, in <module>
req_body_json = """{{
IndexError: Replacement index 7 out of range for positional args tuple
Any support will be welcomed
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide