
How do you know who the original owner of a Onedrive site was?
The url says a lot, it’s usually in a username_domain_com format. If you have a fixed naming structure and don’t use _’s or other characters that are translated to _, it can be reversed with reasonable accuracy, right?
But what if you have two people with the same name? Or did some migrations or takeovers? Then your logic breaks 🙁
So reverse engineering the URL won’t work, and if an admin takes ownership or if the user leaves and the manager gets ownership, the Owner/Full Control ACL on the site also won’t tell you who the original owner was because it overwrites the Owner property.
In M365permissions the option to audit ownership of Onedrive is built in, as this is a common question during certain types of audits.
But how did we solve it there?
Well, it turns out that Sharepoint’s own metadata service maintains a pretty good track record of who was ever a user on a site, even after they are deleted from Entra.
Thus by doing a call to /_api/web/siteusers?$orderby=Id, we get a nicely ordered list of all users ever assigned to the site.
Pick the first non-system user, and we have our original user! See above 🙂

