Search code examples
desire2learn

Retrieve UserID to Change a users Password


I am working on a process to change a users password in D2L via the API. I'm using PHP.

I need to push a users password change to D2L from another system. Example when the user changes their password in our Portal, I want to make a call to update the password in D2L via the API. In looking over the docs and I need the users "UserID" to make the PUT call as such:

PUT system/d2l/api/lp/1.0/users/UserID/password
{"Password": "HelloWorld5"}

How to I obtain this UserID? I can do a WhoAmI call but that is only valid for the logged in user. I do not see an api that I can call up the users account by UserName and obtain their UserID.

  • Keep in mind the user will not be logging into D2L during this password change and the portal does not have the UserID stored in it. So I need to be able to obtain the userid and then make the password change call.

Solution

  • To get the user ID for a user based on their username, use the following call:

    /d2l/api/lp/{VERSION}/users/

    It can take the username as an argument (userName) otherwise it will return a complete (but paged) list of users. Note that this call requires sufficient (administrator/etc. privileges.)