cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
819
Views
0
Helpful
3
Replies

Deleting users in Unity connection

m.batts
Level 4
Level 4

Just looking at deleting a user from unity connection.

From what I can see it only allows you to delete based on object id rather that alias etc.

Am I missing something?  as it seems a massive pain to get all the details and then have to sort through them to then get the valid object id.

3 Replies 3

Geevarghese Cheria
Cisco Employee
Cisco Employee

jocreed
Cisco Employee
Cisco Employee

I believe the post gcheriais referring would be helpful.  I have a python script around here that does fairly painlessly as well, let me see if I can locate and post the code.

jocreed
Cisco Employee
Cisco Employee

Mark,

Sorry about the delay, Try the code I am posting below.  System Specs are Windows 7, Python 2.7.9, using Requests external library Requests: HTTP for Humans — Requests 2.6.0 documentation.

This is a simple base code that should get you started.  Let me know if you have questions.

Base Code Sample:

import requests

import json

#HTTP headers to include

UserHeaders = {'Accept':'application/json', 'content-type':'application/json','connection':'keep_alive'}

#define Alias to be removed

userAlias = 'Alias''

#Define your Unity connection server URL here

UCURL = 'https://<UnityServer>/vmrest/users/?query=(alias is ' + userAlias + ')'

#Forming the request using "Request" library to submit to the server.

ObIDGetResponse = requests.get(UCURL, headers=UserHeaders, auth=('AppUser','password'), verify=False)

#Using the json dot notation call to get the JSON response from the server in a dictionary format for Python to process

UserGet = UserCreationResponse.json()

#Extracting the specific value from the dictionary using the defined keys from the JSON response

UserObId = UserGet['User']['ObjectId']

#Printing the Object ID to console

print UserObId

#Definining the URL used to delete the user

deleteURL = 'https://<UnityServer>/vmrest/users/' + UserObId

#Forming the Delete request using the "Requests" library

UltimateDestruction = requests.delete(deleteURL, headers=UserHeaders, auth=('AppUser', 'password'), verify=False)

#Printing the HTTP response from the server to console

print UltimateDestruction