cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2357
Views
0
Helpful
1
Replies

Creating internal user' Python script

Hi all,

i am trying to  create  internal user python script  for  ISE but  i can encouter an error while excute my code . Below is my my code and i have already enable  TLS 1.0 Aand TLS 1.1 . Thsi is my cmmand

 

python Internal_user.py 192.168.31.16 ersadmin oFlPRbe1 ab200 Kwame Brown Password1 kwame.brown@gh.co.uk 2021-01-30

 

 

#!/usr/bin/env python

import http.client
import base64
import ssl
import sys
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

#parameters
name = sys.argv[4] # "ab200"
first = sys.argv[5] # "Kwame"
last = sys.argv[6] # "Brown"
passwd = sys.argv[7] # "Password1"
email = sys.argv[8] # "kwame.brown@gh.co.uk"
expiry_date = sys.argv[9] # "2021-12-30"

# host and authentication credentials
host = sys.argv[1] # "192.168.31.16"
user = sys.argv[2] # "ersadmin"
password = sys.argv[3] # "oFlPRbe1"

 

conn = http.client.HTTPSConnection("{}:9060".format(host), context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))

creds = str.encode(':'.join((user, password)))
encodedAuth = bytes.decode(base64.b64encode(creds))

req_body_json = """ {{
"InternalUser" : {{
"name" : "{}",
"enabled" : true,
"email" : "{}",
"password" : "{}",
"firstName" : "{}",
"lastName" : "{}",
"changePassword" : true,
"expiryDateEnabled" : true,
"expiryDate" : "{}",
"enablePassword" : "{}",
"customAttributes" : {{
}},
"passwordIDStore" : "Internal Users"
}}
}}
""".format(name,email,passwd,first,last,expiry_date,passwd)

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)

res = 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('-'*80)
print(req_body_json)
print('-'*80)

 

this is  my error

ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1123)

 

Any suggestion are welcomed .

 

1 Accepted Solution

Accepted Solutions

thomas
Cisco Employee
Cisco Employee

See my response to @Richie20 in the post Creating Internal users by python and argparse.

It includes a templating example.

 

View solution in original post

1 Reply 1

thomas
Cisco Employee
Cisco Employee

See my response to @Richie20 in the post Creating Internal users by python and argparse.

It includes a templating example.

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: