cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
234
Views
0
Helpful
1
Replies
Highlighted
Beginner

Python AXL - Case Sensitive Problem

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 = ""

}

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: Python AXL - Case Sensitive Problem

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).

1 REPLY 1
Cisco Employee

Re: Python AXL - Case Sensitive Problem

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).

CreatePlease to create content
Content for Community-Ad
August's Community Spotlight Awards
This widget could not be displayed.