02-02-2016 02:12 PM
Does anyone know of a way to list a user without knowing the case? Here's my example:
def check_user(user_name):
user = active_cm.service.listUser({'userid': user_name},
{'userid': '',
'firstName': '',
'lastName': ''})
for each in user['return']['user']:
print('Is this the correct user?\n',
'User ID: ' + each['userid'] + '\n',
'First Name: ' + each['firstName'] + '\n',
'Last Name: ' + each['lastName'])
This works fine when I put in the correct case, but if I don't know it then it throws and error (TypeError: string indices must be integers) because the return is empty as seen below:
(reply){
return = ""
}
Solved! Go to Solution.
02-02-2016 02:29 PM
I can't think of a way to make that work with listUser - it might be a useful enhancement to make some or all of the listXXX request string fields case-insensitive...
You can use executeSqlQuery to get the result you're looking for:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/10.5">
<soapenv:Header/>
<soapenv:Body>
<ns:executeSQLQuery>
<sql>select userid from enduser where LOWER(lastname)=LOWER("LABuser1")</sql>
</ns:executeSQLQuery>
</soapenv:Body>
</soapenv:Envelope>
------------------------------------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:executeSQLQueryResponse xmlns:ns="http://www.cisco.com/AXL/API/10.5">
<return>
<row>
<userid>labuser1</userid>
</row>
</return>
</ns:executeSQLQueryResponse>
</soapenv:Body>
</soapenv:Envelope>
however there may be a (potential) significant performance impact from the LOWER(lastname) function, in that it may cause the query engine to do a full table scan on the userid/lastname fields, vs. using an index. Would be good to test against a large data set (50K users).
02-02-2016 02:29 PM
I can't think of a way to make that work with listUser - it might be a useful enhancement to make some or all of the listXXX request string fields case-insensitive...
You can use executeSqlQuery to get the result you're looking for:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/10.5">
<soapenv:Header/>
<soapenv:Body>
<ns:executeSQLQuery>
<sql>select userid from enduser where LOWER(lastname)=LOWER("LABuser1")</sql>
</ns:executeSQLQuery>
</soapenv:Body>
</soapenv:Envelope>
------------------------------------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:executeSQLQueryResponse xmlns:ns="http://www.cisco.com/AXL/API/10.5">
<return>
<row>
<userid>labuser1</userid>
</row>
</return>
</ns:executeSQLQueryResponse>
</soapenv:Body>
</soapenv:Envelope>
however there may be a (potential) significant performance impact from the LOWER(lastname) function, in that it may cause the query engine to do a full table scan on the userid/lastname fields, vs. using an index. Would be good to test against a large data set (50K users).
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: