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

Python AXL - Case Sensitive Problem

Jacob Webb
Level 1
Level 1

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

dstaudt
Cisco Employee
Cisco Employee

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

View solution in original post

1 Reply 1

dstaudt
Cisco Employee
Cisco Employee

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

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: