I am trying to resolve a list of principal ids into the details like name of the user/service. I have the following code -
from azure.common.credentials import ServicePrincipalCredentials
from azure.graphrbac import GraphRbacManagementClient
TENANT = 'something.onmicrosoft.com'
TENANT_ID = '...'
CLIENT_ID = '...'
SECRET = '...'
List_of_Principal_IDs= ['...','...']
credentials = ServicePrincipalCredentials(
client_id=CLIENT_ID,
secret=SECRET,
tenant=TENANT_ID,
resource="https://graph.windows.net"
)
client = GraphRbacManagementClient(credentials, TENANT)
I tried following the advice on on one of the stackoverflow pages but I am running into errors (see following). Any guidance on how I can resolve these principal ids to human understandable format would be appreciated.
users = client.users.list(
filter=f"principal_id eq '{List_of_Principal_IDs[0]}'"
)
test = users.next()
Error -
azure.graphrbac.models.graph_error_py3.GraphErrorException: Property 'principal_id' does not exist as a declared property or extension property.
users = client.objects.get_objects_by_object_ids(List_of_Principal_IDs[0])
user = users.next()
Error -
msrest.exceptions.SerializationError: Unable to build a model: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get', DeserializationError: Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'