Password Generation - MS Graph

Ayan Usmani 171 Reputation points
2022-10-30T13:59:12.453+00:00

I am creating a user using MS API to create user. While doing so I am randomly generating a password via my python script which is being send in the api request body.

But it fails due to password not complying the complexity.

Is there any way to get random password genearated from MS api OR any suggested library in python which complies with MS password complexity policy.

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Dillon Silzer 57,826 Reputation points Volunteer Moderator
    2022-10-30T19:50:52.22+00:00

    Hi @Ayan Usmani

    Password requirements:

    255407-image.png

    Cited from https://learn.microsoft.com/en-us/azure/active-directory/authentication/concept-sspr-policy

    Python:

    import random  
    import string  
      
    # get random password pf length 8 with letters, digits, and symbols  
    characters = string.ascii_letters + string.digits + string.punctuation  
    password = ''.join(random.choice(characters) for i in range(8))  
    print(password)  
    

    Cited from https://pynative.com/python-generate-random-string/

    Reference to Create User (Graph API):

    https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=http

    -------------------------------------------

    If this is helpful please accept answer.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.