I'm trying to print a certain key from a loop and getting some issues. Tried to search other responses but still having issues.
import json
from azure.graphrbac import GraphRbacManagementClient
from azure.graphrbac.models import UserCreateParameters, PasswordProfile
from azure.common.credentials import UserPassCredentials
admin_user_name = ''
admin_password = ''
# e.g. yourcompany.onmicrosoft.com
tenant_id = ""
credentials = UserPassCredentials(
admin_user_name,
admin_password,
resource="https://graph.windows.net"
)
graphrbac_client = GraphRbacManagementClient(
credentials,
tenant_id
)
users = graphrbac_client.users.list();
for user in users:
print [user['mail_nickname']]
the key I only want to extract is called mail_nickname
I get this error
TypeError: 'User' object has no attribute '__getitem__'
I only do print(user) that works fine but loads data I don't need.
Any help would be appreciated. Thanks
user, e.g.user.mail_nickname?