Change password of a user in windows azure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

send_password_azure.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/python
  2. import sys
  3. from azure.common.credentials import UserPassCredentials
  4. from azure.graphrbac import GraphRbacManagementClient
  5. from azure.graphrbac.models import PasswordProfile, UserUpdateParameters
  6. from ConfigParser import SafeConfigParser
  7. login = sys.argv[1]
  8. newpassword = sys.argv[2].decode('base64')
  9. try:
  10. mail = sys.argv[3]
  11. except:
  12. mail = ''
  13. ## Get confgiruation
  14. config = SafeConfigParser()
  15. config.read('/etc/azureconf/azure.conf')
  16. mailadmin = config.get('common', 'mailadmin')
  17. passwordadmin = config.get('common', 'passwordadmin')
  18. tenantid = config.get('common', 'tenantid')
  19. def main():
  20. credentials = UserPassCredentials(
  21. mailadmin, passwordadmin, resource="https://graph.windows.net"
  22. )
  23. graphrbac_client = GraphRbacManagementClient(
  24. credentials,
  25. tenantid
  26. )
  27. param = UserUpdateParameters(
  28. password_profile=PasswordProfile(
  29. password=newpassword,
  30. force_change_password_next_login=False
  31. )
  32. )
  33. user = graphrbac_client.users.update(mail, param)
  34. main()