question

AAD0506-8620 avatar image
0 Votes"
AAD0506-8620 asked AAD0506-8620 commented

(Azure AD)How to duplicate an existing user to create a new user

Hi,

I want to duplicate an Azure AD user to create a new user.
Or it is passible that to copy attributes such as "jobTitle" and "officeLocation" from an existing user to a new user.

Thanks,

azure-ad-identity-governance
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

amanpreetsingh-msft avatar image
0 Votes"
amanpreetsingh-msft answered AAD0506-8620 commented

Hi @AAD0506-8620 • Thank you for reaching out.

You can duplicate Azure AD users by using Graph API using the below steps:

  1. Open Graph Explorer and sign in with the Global Administrator or User Administrator account. Make sure you use a Member user and not a guest user to connect to the correct tenant.

  2. Run GET https://graph.microsoft.com/v1.0/users/object_id_of_source_user_account or GET https://graph.microsoft.com/v1.0/me to get signed in user attributes. Copy the response JSON and remove the lines highlighted in Red.
    199559-image.png

  3. Run POST https://graph.microsoft.com/v1.0/users and in the body, paste the content copied in the previous step. Update the attributes such as GivenName, Surname, UPN, etc., and append the below-highlighted content in the request body.
    199558-image.png

In the response, you will get HTTP 201 Created and the user will be created in Azure AD.

Note: You can use the Beta endpoint ( GET https://graph.microsoft.com/beta/users/object_id_of_source_user_account ) to see the extensive list of all the attributes of the source user. If you want to get specific attributes use the $select parameter e.g., GET https://graph.microsoft.com/v1.0/users/object_id_of_source_user_account?$select=jobTitle,officeLocation,displayName to get only the specified attributes:
199550-image.png


Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


image.png (52.2 KiB)
image.png (71.2 KiB)
image.png (17.7 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you so much for your detailed explanation.
But I can't create a user by Graph Explorer.(I can create a user by Azure Portal.)
This is the error message.


{
"error": {
"code": "",
"message": "No HTTP resource was found that matches the request URI 'https://outlook.office365.com:444/profile/v1.0/users('CID:9e3aba37a129b904')/profile?api-version=AGSV1-internal'.",
"innerError": {
"date": "2022-05-09T02:28:21",
"request-id": "130c4e0e-a141-4ad2-b664-5dce6a03f1f0",
"client-request-id": "89995e31-c15a-89f6-9a27-336d99601bad"
}
}
}

0 Votes 0 ·

@AAD0506-8620 · Please share the screenshot of the API Call and Request Body hiding all the personal information.

0 Votes 0 ·

First, I got the my user information as below.

200232-get-user.png



Second I trie to create the user by the default setting except for "userPrincipalName".
But the error "No HTTP resource was found that matches the request URI...".

200251-create-user.png


0 Votes 0 ·
get-user.png (36.3 KiB)
create-user.png (89.4 KiB)