This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

To Delete a user in Sophos UTM9 through API python script.

I am trying the below code to delete the user with the api url given REF_AaaUseTest but i am getting the response of confirmation and how can i proceed further or how can i give further input for that response to delete the user?

import requests
import base64
import json
import time
import sys
from requests.auth import HTTPBasicAuth
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

def main():
    try:
       url = ("https://1.123.123.123:4444/api/objects/aaa/user/REF_AaaUseTest")       #1.123.123.123:4444 - sample firewall ip
       headers={
         "Accept": "application/json"
       }
       response = requests.delete(url,verify=False, headers=headers,auth=('username','pswrd')).content.decode("utf-8")
       response = json.loads(response)
       print(response)
    except Exception as e:
       print("\nFailed to delete user")
       print("\nerror : ",e)
if __name__ == '__main__':
    main()
    

MyOutpyt:

[{
'name': "Are you sure that you want to delete the user object 'usertest'?",
'rights': '',
'attrs': ['objname'],
'Oattrs': ['class', 'type'],
'objname': 'usertest',
'del_object': '',
'ref': 'REF_AaaUseTest',
'msgtype': 'OBJECT_DELETE_REALLY',
'format': "Are you sure that you want to delete the %_O object '%s'?",
'class': 'aaa',
'type': 'user',
'perms': '',
'never_hide': 0,
'fatal': 0
}]

I tried few things but those didn't worked for me with referrals so what modifications need to be done in my code and api url ? can anyone help out of this ! A Very Thanks In Advance.



This thread was automatically locked due to age.